git-rm -cached会在拔出时删除另一个用户的工作树文件 [英] Will git-rm --cached delete another user's working tree files when they pull

查看:109
本文介绍了git-rm -cached会在拔出时删除另一个用户的工作树文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经收集了 git rm --cached FILE 会让我这样做。但是,如果有其他人提出这个改变,他们的本地副本是否会被删除?

是的,他们的副本将被自动删除。想象一下,如果这种删除不会发生 - 那么所有用户的工作副本将会被成堆的删除文件污染,而这些文件已不再需要。



但是,如果远程用户对这些文件进行了本地更改,它们不会被删除,因为 pull 会导致合并冲突。



正如 Jefromi 在他的评论中所建议的,当文件在其他用户身上被移除时,他们很容易被恢复 - 他们受版本控制,不是吗? ;-)文件可以通过 git checkout< revision> - < files ...> 。作为修订,你可以指定前一个提交的id,将它保存在 ORIG_HEAD 中(参见这个问题):

  git checkout ORIG_HEAD -  removed_file 


I wish to stop tracking files but still keep them in my working tree.

I've gathered that git rm --cached FILE will let me do that. However, if someone else pulls this change, will their local copies be deleted?

解决方案

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

这篇关于git-rm -cached会在拔出时删除另一个用户的工作树文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆