撤消git pull --rebase?

use*_*701 5 git

我跑了

git pull --rebase
Run Code Online (Sandbox Code Playgroud)

并忘记指定"原产地".看起来git从所有不同的分支中拉出来.有没有办法从这里恢复我的回购撤消拉?

谢谢

lar*_*sks 8

一个git pull操作后,ORIG_HEAD应该指向前一个值HEAD.你应该能够:

git reset --hard ORIG_HEAD
Run Code Online (Sandbox Code Playgroud)

并且回到pull手术前的起点.你可以运行:

git show ORIG_HEAD
Run Code Online (Sandbox Code Playgroud)

ORIG_HEAD在运行reset命令之前确切地查看指向的位置.

另一种解决方案是基于以下方式创建新分支ORIG_HEAD:

git checkout -b newbranch ORIG_HEAD
Run Code Online (Sandbox Code Playgroud)

验证事物是否符合预期,然后删除旧分支并重命名new branch.

也看到这个问题的的讨论HEAD,并ORIG_HEAD为指的是同一件事和替代语法.


Pet*_*oes 5

git reflog

你会看到一大堆过去的提交 HEAD。

最安全的是在新分支中签出您需要的 HEAD 并从那里继续

git checkout -b phew HEAD@{x} # fill in the number of the commit you need.
Run Code Online (Sandbox Code Playgroud)