Let's say I have a .noise
file in the root of my repository. This file is frequently modified and committed to the remote repo by others on my team.
I want to completely ignore this file while I'm committing anything myself, but I still want to pull in the changes from the others, and I don't want to delete the file. If I use .git/info/exclude
, then I have to git rm --cached
the file so it doesn't show up in the repo.
Now doing that brings me from:
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: .noise
#
# No changes added to commit (use "git add" and/or "git commit -a")
to:
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: .noise
#
The 'Changes to be committed' scares me. I don't want to push the deletion of .noise
back to the remote, I don't want it deleted on my filessytem either. I just don't want Git to see or have anything to do with it. I thought that git rm --cached
was not supposed to stage any changes? Is that not so?
Any ideas?
If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.
You can use:
$ git update-index --assume-unchanged -- .noise
update-index --assume-unchanged
will make Git continue to track the file, but your changes won't be reflected in the index or added to the repo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With