恢复 git reset 后在仓库中不再显示的文件

3

有人执行了git reset --hard f7fe845,并将其推送到存储库中的一个分支。

现在在该分支中,我们看不到该提交之前的任何工作。实际上,这使得该分支上的所有工作都丢失了。

我们需要撤消该git reset,并让该分支回到先前的版本,但至少在git网站或source-tree上,就像其他提交不存在一样。

有没有希望恢复信息?如何操作?

我的分支是feature/UAL-117

[ec2-user@ame]$ git reflog
8c0136d HEAD@{0}: reset: moving to HEAD~1
f7fe845 HEAD@{1}: checkout: moving from develop to feature/UAL-117
f7fe845 HEAD@{2}: checkout: moving from feature/UAL-117 to develop
f7fe845 HEAD@{3}: checkout: moving from develop to feature/UAL-117
f7fe845 HEAD@{4}: checkout: moving from feature/UAL-117 to develop
f7fe845 HEAD@{5}: reset: moving to f7fe845df3efc0a6b79b4ccde50ab08fc542532f
6a03be3 HEAD@{6}: checkout: moving from develop to feature/UAL-117
f7fe845 HEAD@{7}: checkout: moving from f7fe845df3efc0a6b79b4ccde50ab08fc542532f to develop
f7fe845 HEAD@{8}: checkout: moving from feature/UAL-117 to f7fe845df3efc0a6b79b4ccde50ab08fc542532f
6a03be3 HEAD@{9}: pull: Fast-forward
24e9afe HEAD@{10}: pull: Fast-forward
d238450 HEAD@{11}: checkout: moving from develop to feature/UAL-117
f7fe845 HEAD@{12}: pull: Fast-forward
8c0136d HEAD@{13}: checkout: moving from feature/UAL-117 to develop
d238450 HEAD@{14}: checkout: moving from feature/UAL-117 to feature/UAL-117
d238450 HEAD@{15}: checkout: moving from develop to feature/UAL-117
8c0136d HEAD@{16}: checkout: moving from feature/UAL-117 to develop
d238450 HEAD@{17}: commit (merge): feature/UAL-117 update composer.lock
dd89670 HEAD@{18}: checkout: moving from develop to feature/UAL-117

2
你在某台机器上有一个仓库还没有拉取吗? - Mark Seemann
1
不用担心,我相信你不会丢失任何提交记录。你能否放置gitk图形或更多相关信息? - rajuGT
1
git reset --hard 238450? - sergej
1
@sergej 我爱你!太棒了! - Jonathan Thurft
1
@sergej:为什么不像Stas建议的那样使用6a03be3 - quetzalcoatl
显示剩余11条评论
2个回答

1
如果问题是由于重置到 f7fe845 导致的,请尝试

git reset --hard 6a03be3

1

你可以运行:

git reflog

我希望在输出中看到类似于 "d238450 HEAD@{17}: commit ...." 的内容。

然后:

git reset --hard <commit>

<commit> 指向您希望还原的快照(例如:d238450)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接