开发者

How can I revert my changes using 'git pull'?

I did a 'git pull' instead of a 'git pull --rebase'.

SHA: 138937298d80a7c84d0630b1db509ca2596aca91  // top of my git

<< some changes I got from 'git pull' >>
SHA:

SHA:
<< end of some changes I got from 'git pull' >>

SHA: 08ebb55902e206a30d6f344b4684bd525970dda3  // m开发者_StackOverflow社区y original top of my git before i do anything.

My question is how can I revert the changes I got from 'git pull' and then I do a 'git pull --rebase' ?

Another question is I am using 'gitx' on Mac, the changes I got from 'git pull' are on a different vertical line and the ones I originally have. Why is that? Thank you.


Find the other HEAD you want to revert to using git reflog and then reset to the commit. Usually, if you didn't do anything after the pull, this would be git reset --hard HEAD@{1}


Let's say you're on master and you want to pull in remote changes to origin/master and rebase your work onto the "official" branch, but you made a mistake:

git pull origin

Now you've got a merge of your work and the stuff from the server; that's not what you wanted!

git stash save
git reset --hard HEAD@{1}
git stash apply

Now you're back where you were before the pull, but you still want to put your changes on top of what was on the server...

git rebase origin/master

There you go, all set!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜