开发者

Ignoring files already in a repo WITHOUT deleting them

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜