Reputation: 203
Currently working on a branch off master, and added something to .gitignore. I committed all my changes and tried checking out another branch but I get:
error: Your local changes to the following files would be overwritten by checkout:
.gitignore
Please, commit your changes or stash them before you can switch branches.
Aborting
When i run git status
, I get:
On branch feature/blahblah
nothing to commit, working directory clean
Does this mean git is not tracking my .gitignore file? If so, how do I get it to recognize the file?
Upvotes: 0
Views: 726
Reputation: 203
So, if this happens to anyone, somehow, someway, run:
git rm --cached .gitignore
Upvotes: 1
Reputation: 36678
Did you, by chance, add a .gitignore
line to your .gitignore
file, so that it's ignoring itself? If so, remove it; it's best not to ignore the .gitignore
file. Other places besides .gitignore
that might be responsible are your global core.excludesfile
setting, or a .git/info/excludes
file in your repository (which would not get checked in). Neither of these are good practice in general, but some specific cases might require them (e.g., one developer uses a different editor than the other people on the project so he needs a different set of ignored files), so the options are available. See https://help.github.com/articles/ignoring-files/ for more details.
That seems most likely to be your problem.
Upvotes: 1