恢复带有git历史记录的已删除文件 [英] Restore deleted file with history in git
本文介绍了恢复带有git历史记录的已删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在推送后在git中还原意外删除的文件和文件夹.下面是场景.
How to restore an accidentally deleted file and folder in git after push. Below is the scenario.
- 无意中删除了一个包含单个文件的文件夹,并对其他文件进行了一堆更改.
- 现在,推动所有这些更改.因此,此推送具有已删除的文件夹以及其他已更改的文件.
- 最重要的是,还有一些推动作用.
现在,我可以还原已删除的文件以及历史记录,然后再推回存储库.
Now, can I restore the deleted file, along with history and then push back to repo.
推荐答案
当然,只要从它存在的提交中检出即可.如果删除文件的提交是您当前已签出的内容的提示,则为HEAD^
(最后提交之前的提交):
Sure, just check it out from a commit where it existed. If the commit that deleted the file is the tip of whatever you have currently checked out, that’s HEAD^
(the commit before last):
git checkout HEAD^ -- path/to/file
然后您可以提交并推送它.
Then you can commit and push it.
这篇关于恢复带有git历史记录的已删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文