Reputation: 333
I had some local commits and there were changes made on master. So I did a:
git pull // it automatically merged and had a conflict with one file only.
subl <file> // Made the wrong fix and saved it
git commit // It opened nano and I Typed "fixed merge" saved it
git push master origin
How do I go back to before the pull and redo the merge and push? Especially get back to right before the merge.
Upvotes: 3
Views: 4514
Reputation: 2924
You can revert that merge with:
git revert -m 1 (Commit id of the merge commit)
More informations can be found in Official GUIDE
And you can do it in other way by using git reflog <branch>
to find out where your branch was before the merge, and git reset --hard <commit_id>
to restore the old revision (you will get back to this commit). Then just you can push
it back.
Reflog will show you older states of the branch, so you can return it to any change set you like.
Make sure you are in correct branch
Upvotes: 6
Reputation: 1
You can revert to the last commit:
git revert HEAD
It will revert your commit as a new commit
Upvotes: 0