gitignore Not Working For File/Folder Even Path Given

  • 07-09-2022
  • 524
  • Gitlab
  • Haresh Chauhan

Git ignores may sometime not work even though the add files or folder inside the git ignore file. In the event, you define the proper path but you still getting track of your application file or folder you just need to start working git ignore to un track your application files and folder for the git commit.

If you failed to ignore your file from the untracking and it may not work properly I will teach you in this post how you register a file or folder in the git ignore file and different methods to add the file in git ignore.

There are two ways, you can add a file or folder in .gitignore, by direct adding path and comment method.

In the .gitignore file with the folder/file name, you want to ignore. You can use any one of the formats below given mentioned method.

Method 1. Gitignore File/Folder Registration

For example, if you don`t want to track node_modules in git commit you can register your file/folder like this.

node_modules/
node/

Method 2. Gitignore File/Folder Registration

You can also register your file/folder in the .gitignore file like below.

**/frontend/node_modules/**
**/frontend/node/**

Fix Gitignore Issue.

Commit your all changes to git. Now Exclude the folder/files you don't that don't want to commit. Here in my case, I want to ignore node_modules.

Now Execute the below-suggested command in your application terminal.

git rm -r --cached .

Now execute.

git status
git add .
git commit -m "untracked node modules files" 

We always thanks to you for reading our blogs.


dharmesh-image

Dharmesh Chauhan

(Swapinfoway Founder)

Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us

haresh-image

Haresh Chauhan

(Co-Founder)


We Are Also Recommending You :