Git pull - 删除的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7098586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git pull - deleted files
提问by Mecca
I have a development server and a couple of production ones. I do commits from the dev to a remote repository and have git push production
setup, that issues a pull from the production servers.
I needed to remove a couple of directories with static files from being tracked so I did this
我有一个开发服务器和几个生产服务器。我确实从开发人员提交到远程存储库并进行了git push production
设置,从生产服务器发出拉取请求。我需要从跟踪中删除几个带有静态文件的目录,所以我这样做了
Remove an Existing File from a Git Repo(summary: did git rm --cached myfolders
, and after that added to .gitignore the folders)
从 Git 存储库中删除现有文件(摘要: did git rm --cached myfolders
,然后添加到 .gitignore 文件夹)
I have not yet committed the changes. The files show as deleted when doing git status
我还没有提交更改。执行时文件显示为已删除git status
# deleted: file1.jpg
# deleted: file2.jpg
# deleted: file3.jpg
# deleted: file4.jpg
# deleted: file5.jpg
My concern is: will the 'deleted' files be removed from production servers (from disk) when git pull
is being performed?
I just want them untracked, but not deleted from disk.
我担心的是:git pull
执行时是否会从生产服务器(从磁盘)中删除“已删除”的文件?我只是希望它们不被跟踪,但不会从磁盘中删除。
Thanks
谢谢
回答by Amber
Yes, if you pull a commit that includes deletions, the files will be deleted. You'll need to restore the files manually afterwards.
是的,如果您拉取包含删除的提交,文件将被删除。之后您需要手动恢复文件。
回答by Greg Hewgill
Yes, the files will be deleted if you do a git pull
. Git couldn't do anything else - suppose some code in the repository depended on the existence or non-existence of some file. Removing a file might have a significant resulting behaviour, so Git must remove the file when pulling.
是的,如果您执行git pull
. Git 不能做任何其他事情 - 假设存储库中的某些代码取决于某些文件的存在或不存在。删除文件可能会产生显着的结果行为,因此 Git 必须在拉取文件时删除该文件。