Will git-rm --cached delete another user's working tree files when they pull

无人久伴 提交于 2019-11-28 20:36:05
P Shved

Yes, their copies will be automatically deleted. Imagine if this deletion wouldn't happen--then working copies of all users would be polluted with piles of deleted files, which aren't needed anymore.

However, if the remote users made local changes to these files, they won't be deleted, since pull will result in a merge conflict.

As Jefromi suggests in his comment, while the files are removed at the other users' sides, they can easily be restored--they're under a version-control, aren't they? ;-) Files could be gotten by git checkout <revision> -- <files...>. As revision you may specify the id of the previous commit, for pull it's saved in ORIG_HEAD (see this question for details):

git checkout ORIG_HEAD -- removed_file

In such a case I would rather ignore them locally only :

If they are already tracked :

git update-index --skip-worktree FILE

If they untracked : add them to your local exclude file

echo "FILE" >> .git/info/exclude

You can also have global .gitignore if its something you will do for all your repos (e.g. *~)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!