从git中删除文件 [英] removing files from git
问题描述
我知道我可以从跟踪中删除一个文件,并使用 git rm< file>
I know I can remove a file from tracking and have it deleted with git rm <file>
或者如果我想保留该文件并将其从跟踪中删除,可以使用 git rm --cached< file>
or if I want to keep the file and just remove it from tracking I can use git rm --cached <file>
但是当我将其推送到存储库并且其他人从中拉出时,这会产生什么影响?有意义的是, git rm --cached< file>
会将它从跟踪中移除,并且它们仍然在目录中,但是<$ c $> c> git rm< file> ,它只会从其他用户的跟踪中删除文件,还是会在删除文件后删除实际文件?
but what are the repercussions of this when I push it to the repository and other people pull from it? Makes sense that git rm --cached <file>
would just remove it from tracking for everyone and they still have the file in their directory, but what about git rm <file>
, will it just remove the file from tracking for other users or will it delete the actual file for them once they pull as well?
推荐答案
它也会为他们删除该文件。实际上,在这两种情况下都会发生 - 无论是否使用 - cached
或不是,因为最终提交的内容将是同一件事:删除文件。
It will delete that file for them, too. Actually that will happen in both cases - no matter if you use --cached
or not since what you eventually commit will be the same thing: The deletion of the file.
这篇关于从git中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!