Git rebase --abort使我所有的提交都消失了,有没有办法恢复它们?

我上个月开始了我的项目,到目前为止已完成了150次。

我也定期推,我的最后推是今天早上。因此,我的工作并没有完全丢失,但是我想知道是否可以进行本地恢复,以恢复我的上一次提交(在推送之后进行)。

这是怎么回事:

  • 今天早上,我还原了两天前的一次提交。 AFAIK,一切顺利。从那以后,我一直在努力工作。

  • 今天下午,我意识到我的最后2个提交可以合并。所以我尝试了git rebase --interactive。但是Git回答:

I wonder if you are in the middle of another rebase.  If that is the
case,please try
        git rebase (--continue | --abort | --skip)
If that is not the case,please
        rm -fr ".git/rebase-merge"
and run me again.  I am stopping in case you still have something
valuable there.

我认为我是由于最近的恢复工作,所以做了git rebase --abort。我做错了。我几乎所有的提交都消失了,git log仅显示上个月的前3个。我想从那以后我有一个待定的基准。

有没有办法还原该重新设置--abort?

感谢您的阅读和帮助。

编辑:这是git状态:

On branch master
Your branch is behind 'origin/master' by 147 commits,and can be fast-forwarded.
  (use "git pull" to update your local branch)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .vscode/
        __pycache__/
        main.py
        venv/

nothing added to commit but untracked files present (use "git add" to track)

编辑:这是git reflog(我想回到f0b2519):

6b634e3 (HEAD -> master) HEAD@{1}: rebase -i (abort): updating HEAD
f0b2519 HEAD@{2}: commit: Add comments in params
da4f6b7 HEAD@{3}: commit: Add comments in params
850ac42 HEAD@{4}: commit: del pygame import in params,adapt main and pygi
3415a2f HEAD@{5}: commit: Put config content in params then delete config
98a8b89 HEAD@{6}: commit: Supress 'if main' in params
72803da (origin/master) HEAD@{7}: checkout: moving from 63cb88ae8d2f1547c7d18882084c06b73d892419 to master
63cb88a HEAD@{8}: checkout: moving from master to branch2
72803da (origin/master) HEAD@{9}: revert: Revert "Move switcher in pgi.press_key()"       
3f3ccb6 HEAD@{10}: checkout: moving from branch2 to master
63cb88a HEAD@{11}: checkout: moving from branch2 to branch2
63cb88a HEAD@{12}: revert: Revert "Move switcher in pgi.press_key()"
3f3ccb6 HEAD@{13}: checkout: moving from master to branch2
3f3ccb6 HEAD@{14}: checkout: moving from branch2 to master
3f3ccb6 HEAD@{15}: checkout: moving from master to branch2
3f3ccb6 HEAD@{16}: commit: Update requirements.txt
ccc6845 HEAD@{17}: commit: Edit docstring in pygameinterface
e4632d2 HEAD@{18}: commit: Linting on config and tool

编辑:git reset --hard f0b2519就像一个咒语一样,真是令人欣慰!非常感谢所有人。

v0zhang 回答:Git rebase --abort使我所有的提交都消失了,有没有办法恢复它们?

Git reflog最有可能是您的朋友和救星。

  

引用日志或“引用日志”记录本地存储库中分支和其他引用的提示何时更新。 Reflog在各种Git命令中很有用,用于指定引用的旧值。例如,HEAD @ {2}表示“ HEAD以前是两个动作之前的位置”,master@{one.week.ago}表示“ master在此本地存储库中以前指向一周的位置”,依此类推。有关更多详细信息,请参见gitrevisions [7]。

这是ohshitgit.com关于reflog的话

  

您可以使用它来恢复意外删除的内容,或者仅删除尝试破坏存储库的某些内容,或者在合并失败后恢复,或者返回到实际起作用的时间。

当我搞砸了时,我在很多场合都使用了reflog。

Whit reflog,您可以通过查看reflog中的特定点来回溯此问题,SO answer可能会进一步阐明问题。

本文链接:https://www.f2er.com/3143535.html

大家都在问