撤消 git pull --rebase
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2213235/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Undoing a git pull --rebase
提问by Thomas
Hey I'm new to git and I need to undo a pull, can anyone help?!? So what I've done is...
嘿,我是 git 的新手,我需要撤消拉动,有人可以帮忙吗?!?所以我所做的是...
- git commit
- git stash
- git pull --rebase
- git stash pop
- 提交
- 混帐
- git pull --rebase
- git stash pop
this created a bunch of conflicts and went a bit wrong. Now doing 'git stash list' reveals that my stash is still there. Is it possible to revert my repo back to the point just after doing git commit. So effectively my repo only contains only changes I have made and nothing new from the server?
这造成了一堆冲突,并且出了点问题。现在做 'git stash list' 表明我的藏匿处还在那里。是否可以在执行 git commit 后将我的 repo 恢复到原点。如此有效地我的 repo 只包含我所做的更改,而没有来自服务器的任何新内容?
回答by Pat Notz
Actually, to make this easier Git keeps a reference named ORIG_HEAD
that points where you were before the rebase. So, it's as easy as:
实际上,为了使这更容易,Git 保留了一个名为的引用ORIG_HEAD
,该引用指向您在变基之前所在的位置。所以,这很简单:
git reset --hard ORIG_HEAD
回答by knittl
using git reflog
you will see a list of commits HEAD pointed to in the past
使用git reflog
您将看到 HEAD 过去指向的提交列表
using
使用
git checkout -b after-commit HEAD@{1} # or the commit you want to recover
you create a new branch at that precise position and check it out
你在那个精确的位置创建一个新的分支并检查它
回答by Erik Martino Hansen
You should checkout the command
你应该签出命令
git reset --merge
That eliminates the need for a git commit; git stash before a pull (Don't know about rebase though)
这消除了对 git commit 的需要;在 pull 之前 git stash (虽然不知道 rebase)
The command returns a workspace with uncommitted changes to the state before a conflicting pull.
该命令返回一个工作空间,其中包含对冲突拉取前状态的未提交更改。
回答by Johan Dahlin
Use git log -g
and find the commit index you want to go back to, the just do git checkout
index
使用git log -g
并找到要返回的提交索引, just do git checkout
index