.gitignore does not appear to be taking effect
I'd like for git to ignore the file named "Doxyfile", I added a .gitignore file but it still tries to track the file.
I added my steps belowm am I missing a step?
$ ls -a
.git .gitignore README
$ cat .gitignore
.DS_Store
Doxyfile
*~
$ touch Doxyfil开发者_如何转开发e
$ ls
Doxyfile README
$ git status -s
?? Doxyfile
If you reached an advanced level of git usage, where you understand how it works and you think it should ignore files and it does not, you only need the following three commands:
git rm -r --cached .
git add .
git commit -m '.gitignore synchronised'
This does all the necessary steps of removing everything from the index add everything back again. But when adding git always looks up the .gitignore
file, at this point, everything mentioned in there will not be added to the index.
.gitignore now does what you expect
The only thing I could think of is that you have an extra space at the end of the "Doxyfile" line in your .gitignore, which would cause this.
It could be a very simple typo.
Make sure there is no spaces neither before nor after the file name in your .gitignore. Adding a space will break the intended behaviour.
Here, I got a similar problem because I missed an 's' in the middle of the configuration variable: Why doesn't my global .gitignore file ignore?
check and double check all the file names involved.
Perhaps Doxyfile has already been added to the repo, even though it's not present locally when you run ls? If so first make a backup of it, then git rm Doxyfile
and make sure it's in your .gitignore. Commit this change. Then move the file back into your repo's folder and this time around it should be ignored by git.
精彩评论