且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

恢复带有git历史记录的已删除文件

更新时间:2023-12-04 21:07:10

当然,只要从它存在的提交中检出即可.如果删除文件的提交是您当前已签出的内容的提示,则为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.