If you are an user of the GIT version control then you must be aware of the .gitignore file. For the ones how are not aware of this file, .gitignore helps you ignore or avoid certain files from being committed into the main repository using GIT.
Now it happens at times that the .gitignore file behaves weirdly and GIT fails to ignore all the file names listed in the .gitignore file and as a result all these files which you do not want to be committed into the repository start getting committed. And when your .gitignore file is not working, its a big mess!
A very very quick fix to this problem would be to get rid of any trailing whitespace in the .gitignore file, if you find one. Also, you should not put any comments next to the listed file in the .gitignore
If all this still does not solve your problem, follow these steps:
Step 1: Commit all your pending changes in the repo which you want to fix.
Step 2: Now you need to remove everything from the git index in order to refresh your git repository. This is safe. Use this command:
git rm -r --cached .
Step 3: Now you need to add everything back into the repo, which can be done using this command:
git add .
Step 4: Finally you need to commit these changes, using this command:
git commit -m ".gitignore Fixed"
Please let us know if you were able to fix .gitignore using these steps.
Related Posts by Tags: git, gitignore