I wanted to squash my last 2 commits into one, so did a git rebase
, in following way:
git rebase -i HEAD~2
but due to a typo, wha
Edit: Check your reflog with
git reflog
Pick the commit previous to your first rebase and replace the x with appropriate number below:
Just undo your last rebase and redo it:
git reset --hard HEAD@{x}
git rebase -i HEAD~2
..
git push -f origin master
Remove your pull request and issue a new one.
Both git reset --hard HEAD{x}
and git reset --hard HEAD@{x}
didn't work for me.
I wanted a script to do this anyways, so I did the following.
BACK_2_SHA=`git reflog show --pretty=format:'%H' -n x | tail -n 1`
git reset --hard $BACK_2_SHA