Sometimes git does not exclude files/folders added
.gitignore especially if you had committed them before. Here is how to fix it.
I am ignoring node_modules from frontend project as an example
.gitignorewith the folder/file name you want to ignore. You can use anyone of the formats mentioned below (prefer format1)
### Format1 ###
node/### Format2 ###
- Commit all the changes to git. Exclude the folder/files you don’t want commit, in my case
- Execute the following command to clear the cache
git rm -r --cached .
git statuscommand and it should output
node_modulesand sub directories marked for deletion
- Now execute
git add .
git commit -m "fixed untracked files"
- That’s it. Comment if you any questions.
Note: Windows users make sure your
.gitignore uses UTF-8 rather than UTF-16. See comment for details