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.
Method 2. Gitignore File/Folder Registration
You can also register your file/folder in the .gitignore file like below.
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 .
git add .
git commit -m "untracked node modules files"
We always thanks to you for reading our blogs.
Dharmesh Chauhan(Swapinfoway Founder)