开发者

Git: untrack a file in local repo only and keep it in the remote repo

I have a NetBeans file "nbproject/project.properties" that always shows up in the "Changes not staged for commit" section (wh开发者_运维知识库en I do git status). How could I move this to the Untracked files section (without adding it to .gitignore) ? I tried this command git rm --cached but what happened is the file shows as untracked in my local repo and got removed in the remote one but what I want is to keep it in remote and untrack only in local repo.


You could update your index:

cd /root/folder/of/your/repo
git update-index --assume-unchanged nbproject/project.properties

and make sure it never shows as "updated" in your current repo.
That means it won't ever be pushed, but it is still present in the index.
(and it can be modified at will in your local working tree).


  • to revert that state (from git-ready):

git update-index --no-assume-unchanged <file>

  • to see all assume unchanged files (from Gabe Kopley's comment)

git ls-files -v | grep '^h '

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜