gitignore not working on all files

2019-01-29 13:32发布

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.

标签: git file ignore
2条回答
Juvenile、少年°
2楼-- · 2019-01-29 13:54

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.

查看更多
叼着烟拽天下
3楼-- · 2019-01-29 13:56

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.

查看更多
登录 后发表回答