Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 5
    If you just want to reset the remote, you can clobber it with anything! But let us use the fourth commit ago: git push -f HEAD~4:master (assuming the remote branch is master). Yes, you can push any commit like that. Commented Sep 23, 2009 at 1:01
  • 41
    If people have pulled you have to make a commit that reverts changes using git revert. Commented Sep 23, 2009 at 8:21
  • 3
    Use git show HEAD~4 to ensure you are pushing to right one to the remote Commented Jun 11, 2016 at 3:08
  • 2
    Possible duplicate of How to undo last commit(s) in Git?
    – Jim Fell
    Commented Feb 14, 2017 at 18:53
  • 9
    "Is the order important?" Yes, if the commits affect the same lines in the same files. Then you should start reverting the most recent commit, and work your way back. Commented Apr 22, 2017 at 11:26