gitignore not working on all files

与世无争的帅哥 提交于 2019-11-28 12:58:50

问题


I am trying to ignore some files from my project. I have the following extensions in .gitignore

*.opensdf
*.sdf
*.tlog
*.cer
*.cat
*.inf
*.tmh
*.inf

I see the following file is ignored

D:\Projects\driver1\driver1\inter\Win32\Win7Debug\link.command.1.tlog 

but the following file is seen as Modified, thus this one is not ignored.

D:\Projects\driver1\ioctlapp\inter\Debug\link.write.1.tlog

Why the second file isn't ignored and how can i fix the problem?

I took only 2 files from both, from ignored and not ignored files, but there are more files which I expect to ignore and they aren't.


回答1:


That's most probably because you committed it before adding *.tlog in your .gitignore.

Use git rm to remove it from git and the commit the changes:

 git rm D:\Projects\driver1\ioctlapp\inter\Debug\link.write.1.tlog
 git commit -m 'Removed link.write.1.tlog'

Next time when you will edit it, it will be ignored.




回答2:


First check if file is tracked git ls-files --error-unmatch file_name If you don't see error, then it's tracked. Remove it from index but not from disk with git rm --cached. After that commit that change. Let me know if it helped you.



来源:https://stackoverflow.com/questions/33101106/gitignore-not-working-on-all-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!