Undo reverse commit source tree

16,073

Solution 1

This is the answer you're looking for.

It shows how to find your committed files in history and reset to them.

Solution 2

If you reseted the head of your branch than you need the old head's sha1. Maybe you can find it in the .git/objects directory by date. (try git show xyz with the suspicious sha's. (suspicious means the modification time can match.))

If you commited a "reverse" commit, than you have to repeat only what you did. (commit an other reverse commit.) Or you can also reset the head to remove the "reverse" commit from your branch's history. (git reset --soft 'HEAD^')

There are a few helpful description: How to undo last commit(s) in Git?

Solution 3

If you get the SHA of the original commit (the one you later reversed) you can cherry-pick that one back to HEAD.

Or you can just reverse the reverse. It will basically be the same thing.

Share:
16,073
Chahal
Author by

Chahal

iOS developer

Updated on June 15, 2022

Comments

  • Chahal
    Chahal almost 2 years

    I have accidently done a reverse commit of a branch on which I was working on. Is there any way to undo that reverse commit and get my changes back?