I have performed git commit followed by a git push. How can I revert that change on both local and remote repositories?
$ git log
commit 364705c23011b0fc6a7ca2d80c86cef4a7c4db7ac8
Author: Michael Silver <Michael Silver@gmail.com>
Date: Tue Jun 11 12:24:23 2011 -0700
(Example push:
git push -f origin bugfix/bug123)This will undo the last commit and push the updated history to the remote. You need to pass the
-fbecause you’re replacing upstream history in the remote.Edit:
Please note that
--hardwill make your commit unreachable (i.e. it will appear to be deleted, but you can stillgit show <hash>orgit log <hash>it if you remember its hash). If you want to keep your changes, run:At this point you have unstaged changes because you used
--mixed, which is the default.You may first want to update the remote tree first (i.e. remove the commit):
git push -f <remote> <branch>Since you still have your changes locally you can create another branch and
committhem there (andpushas you see fit).