From here http://blog.prabir.me/post/Undo-in-Git.aspx, it said
This undo’s your commit and also resets your working tree to the last commit.
1 git reset --hard HEAD^
But how can I un-do my last commit AFTER I did a 'git push'?
Thank you.
When I do 'git log', I get as my top commit
commit 29fc764693a5933a379169e22891e4b0d3d2426f
Merge: 002db49 cfb1d8f
How can I 'git revert' that change?
I get this
$ git revert HEAD
fatal: Commit 29fc764693a5933a379169e22891e4b0d3d2426f is a merge but no -m option was given.
you can use git revert HEAD
, which generates a new commit, which will undo the changes in your previous commit. Look here. Note however that both the commit and the revert commit will show up in the history.
Edit: As KingChrunch mentioned, when reverting a merge commit, you need to specify which parent you want to revert to, so add -m <parent>
. Of course simply following the link I have posted would have told you so.
You can't (well actually shouldn't) modify the history of a shared repository. If you where inclined to modify the history (please don't), you can use git reset
with git push --force
, or git rebase
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With