撤消git pull --rebase吗? [英] Undo a git pull --rebase?
问题描述
我刚跑
git pull --rebase
,忘记指定来源".看起来git从所有不同的分支中拉出.有没有办法从这里还原我的仓库以撤消拉动?
and forget to specify "origin". It looks like git pulled from all different branches. Is there a way to revert my repo from here to undo the pull?
谢谢
推荐答案
git pull
操作之后,ORIG_HEAD
应指向HEAD
的先前值.您应该能够:
After a git pull
operation, ORIG_HEAD
should point to the previous value of HEAD
. You should be able to:
git reset --hard ORIG_HEAD
并返回pull
操作之前的起点.您可以运行:
And be back where you started before the pull
operation. You can run:
git show ORIG_HEAD
在运行reset
命令之前准确查看ORIG_HEAD
指向的位置.
To see exactly where ORIG_HEAD
is pointing prior to running the reset
command.
另一种解决方案是基于ORIG_HEAD
创建新分支:
An alternative solution would be to create a new branch based on ORIG_HEAD
:
git checkout -b newbranch ORIG_HEAD
验证一切看起来与您期望的一样,然后删除旧分支并重命名new branch
.
Verify that things look the way you expect, then delete the old branch and rename new branch
.
另请参阅此问题,以获取对HEAD
和ORIG_HEAD
和用于指代同一事物的备用语法.
Also see this question for a discussion of HEAD
and ORIG_HEAD
and alternate syntaxes for referring to the same thing.
这篇关于撤消git pull --rebase吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!