git合并后还原已删除的文件 [英] git restore a deleted file after merge

查看:701
本文介绍了git合并后还原已删除的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试恢复将分支合并到主服务器时意外删除的文件.

I am trying to recover a file that was accidentally removed when I merged a branch to the master.

现在,当我尝试对新分支进行git checkout时,会显示以下消息:

Now, when I try to do a git checkout of a new branch I get this message:

 $ git checkout testingNewFormStyle
D       module/FormDependencies/src/FormDependencies/Entity/LanguageList.php
Switched to branch 'testingNewFormStyle'

但是,我想还原该文件.我该怎么办?

However, I want to restore that file. How can I do this?

推荐答案

您可以这样做,例如:

git checkout HEAD -- module/FormDependencies/src/FormDependencies/Entity/LanguageList.php

这将检出HEAD refspec中存在的文件(即当前分支).如果HEAD不是您想要的,请替换为适当的refspec.

This will checkout the file as it exists in the HEAD refspec (ie, the current branch). If HEAD is not what you want, replace with the appropriate refspec.

这篇关于git合并后还原已删除的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆