Reputation: 739
Git is an awesome beast of an SCM. Yet I am endlessly perplexed by an issue.
I have a config file which are in the .gitignore
and not in the master
branch on origin
(via git show -- config/mongo.yml
). However on my branch, which was checked out from origin/master
and worked on for a while, the file is being tracked somehow and when I git rm
and git checkout
out from origin/master
again, the files stay in my repo but disappear for everyone else on my team. I ran git rm --cached
as well, and as a last resort I ran:
git update-index --assume-unchanged -- config/mongo.yml
Which I have used many times to good effect on ignored files, and the branch was small enough to redo. However, this doesn't seem to be the fix. I really would just like to know the "why" of this and understand the problem, since that is 3/4 of the solution!! :)
How could I have it in my .gitignore
and then it shows up tracked after git rm config/mongo.yml
and git checkout origin/master -- config/mongo.yml
?
Upvotes: 0
Views: 224
Reputation: 60275
Things I've tried when something's odd:
removing that file from .gitignore and switching to a commit that doesn't have that file (and doesn't have it in .gitignore).
git ls-files --cached --ignored --exclude-standard
in every checkout whose behavior I'm having trouble explaining. I do it every so often anyway.
git log --all --decorate --oneline --graph path/to/your/cuckoo
, that shows everywhere that file's status or contents changed. You can get gitk to do the same thing, bring up a new View.
Also, try cloning to a neighbor directory, it'll hardlink everything but the checked-out content so space isn't a factor. That'll get you a pristine worktree without losing state in your current one, you can experiment there and git clean -dfx
to clean up any messes casually.
Upvotes: 0