是否有可能在快进之前找出提交?

Is it possible to find out the commit before fast-forward?

我做了一个错误的快进合并,主分支指向了一个不应该提交的提交。是否有可能在我执行 fast-forwad 之前找到提交(所以我将 master 分支恢复到该提交)?

我唯一能想到的就是检查你的packed references:

$ cat .git/packed-refs

然后查看您的 master 是否指向对您有意义的先前提交。

您可以使用 git reflog 并签出您想要的提交!

运行 git reflog master 应该有这样的行

bbb222 HEAD@{0}: merge xxxx: Fast-forward
aaa111 HEAD@{1}: foo bar baz

bbb222master的当前提示,aaa111是fast-forward合并前的提示。将 master 恢复为 aaa111

git reset aaa111 --hard

git reset --hard 删除所有未提交的更改。因此,如果您有任何未提交的更改,请先提交或隐藏它们。