Git pull - deleted files

五迷三道 提交于 2019-12-29 08:37:06

问题


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

Remove an Existing File from a Git Repo (summary: did git rm --cached myfolders, and after that added to .gitignore the folders)

I have not yet committed the changes. The files show as deleted when doing 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.

Thanks


回答1:


Yes, if you pull a commit that includes deletions, the files will be deleted. You'll need to restore the files manually afterwards.




回答2:


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.



来源:https://stackoverflow.com/questions/7098586/git-pull-deleted-files

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