5
How to fix "gitignore not working" issue
source link: https://gist.github.com/pavankjadda/2bb6fbdd8786e1f57fd7bcbcc666b51d
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to fix ".gitignore not working" issue?
Sometimes git does not exclude files/folders added .gitignore
especially if you had commited them before. Here is how to fix it. I am ignoring node_modules from Angular project as an example
- Update
.gitignore
with the folder/file name you want to ignore. You can use anyone of the formats mentioned below (prefer format1)
### Format1 ###
node_modules/
node/
### Format2 ###
**/frontend/node_modules/**
**/frontend/node/**
- Commit all the changes to git. Exclude the folder/files you don't want commit, in my case
node_modules
- Execute the following command to clear the cache
git rm -r --cached .
- Execute
git status
command and it should outputnode_modules
and sub directories marked for deletion - Now execute
git add .
git commit -m "fixed untracked files"
- That's it. Comment if you any questions.
Update: Windows users make sure your .gitignore
uses UTF-8 rather than UTF-16. See comment for details
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK