本文介绍了丢失最后一次 Git 提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我丢失了最后一次提交,因为我不小心运行了git reset --hard HEAD^".注意:我不想把^"放在最后.

I lost my last commit because I accidentally ran "git reset --hard HEAD^". Note: I didn't want to put the "^" at the end.

有什么办法可以恢复吗?这是 2 天的工作:(

Is there any way to get it back? It was 2 days of work :(

推荐答案

我认为 这篇文章 正是您要找的.根据文章,您的提交已消失",但并未被垃圾收集 - 有点像 Windows 中的回收站.

I think that this article is what you are looking for. According to the article, your commit is "gone," but not garbage collected - sort of like the recycle bin in Windows.

您运行 git fsck --lost-found 以找到悬空提交",并使用 git reflog 查看它,然后将悬空提交与您当前的提交合并分支,git merge 7c61179.

You run git fsck --lost-found to find the 'dangling commit', and look at it with git reflog, then merge the dangling commit with your current branch, git merge 7c61179.

这篇关于丢失最后一次 Git 提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 10:58