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.

4
  • 12
    Your solution worked fine for me, but with a slight modification. If we have this case Z -> A -> B -> C -> D -> HEAD and if I would want to return to the A state, then weirdly I would have to execute git revert --no-commit Z..HEAD
    – Bogdan
    Commented Feb 22, 2016 at 16:42
  • 3
    Agree with @Bogdan, the revert range is like that: SHA_TO_REVERT_TO..HEAD Commented May 10, 2016 at 16:44
  • 16
    The range is wrong. It should be B^..HEAD, otherwise B is excluded.
    – tessus
    Commented Apr 28, 2018 at 3:50
  • 6
    Agree with @tessus, so the right thing to do would be: git revert --no-commit B^..HEAD or git revert --no-commit A..HEAD
    – Yoho
    Commented Sep 29, 2018 at 0:09