如何撤消git pull? [英] How to undo a git pull?
问题描述
我想撤消我的git pull,因为远程原点上的不需要的提交,但我不知道我必须重新设置哪个修订。
I would like to undo my git pull on account of unwanted commits on the remote origin, but I don't know to which revision I have to reset back to.
我怎么才能回到状态,然后再对远程原点进行git pull?
How can I just go back to the state before I did the git pull on the remote origin?
推荐答案
或者让它比其他答案更明确:
Or to make it more explicit than the other answer:
git pull
哎呀?
git reset --keep HEAD@{1}
1.7.1版以上的git没有 - 保留
。如果您使用此版本,您可以使用 - hard
- 但这是一项危险的操作,因为它会丢失任何本地更改。
Versions of git older than 1.7.1 do not have --keep
. If you use such version, you could use --hard
- but that is a dangerous operation because it loses any local changes.
ORIG_HEAD是HEAD的前一状态,由具有可能危险行为的命令,很容易恢复它们。现在Git有reflog的用处不大:HEAD @ {1}大致等于ORIG_HEAD(HEAD @ {1}总是HEAD的最后一个值,ORIG_HEAD是危险操作前HEAD的最后一个值)
ORIG_HEAD is previous state of HEAD, set by commands that have possibly dangerous behavior, to be easy to revert them. It is less useful now that Git has reflog: HEAD@{1} is roughly equivalent to ORIG_HEAD (HEAD@{1} is always last value of HEAD, ORIG_HEAD is last value of HEAD before dangerous operation)
这篇关于如何撤消git pull?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!