Showing posts with label git reflog. Show all posts
Showing posts with label git reflog. Show all posts

Wednesday, September 2, 2015

Undo a git rebase

Step 1: Identify the head commit of the branch till where you wanted to undo it.

$ git reflog
5621e87 HEAD@{0}: checkout: moving from TISTUD-7562 to development
7747926 HEAD@{1}: rebase -i (finish): returning to refs/heads/TISTUD-7562
7747926 HEAD@{2}: rebase -i (squash): TISTUD-7562:For limited plan billing is not opened via wizard
2101ed5 HEAD@{3}: rebase -i (start): checkout 5621e87fac883fca1783bb2f1b6f811422bdf289
0975830 HEAD@{4}: rebase: aborting
0975830 HEAD@{5}: reset: moving to HEAD@{1}
2101ed5 HEAD@{6}: rebase -i (start): checkout 5621e87fac883fca1783bb2f1b6f811422bdf289
0975830 HEAD@{7}: commit: TISTUD-7562:Avoiding multiple validations during the package launch actions from package explorer and app explorer.
2101ed5 HEAD@{8}: rebase finished: returning to refs/heads/TISTUD-7562
2101ed5 HEAD@{9}: rebase: TISTUD-7562:For limited plan billing is not opened via wizard


Here, I wanted to undo till HEAD@{7}

Step 2: Reset to required commit

git reset --hard HEAD@{7}

This will bring back all the changes which you are having at HEAD@{7} commit.