How to revert / cancel git reset --soft HEAD~20

Viewed 888

i wanted to squash few commits and i followed this so i did :

git reset --soft HEAD~20
git commit
git push -f

I don't know why but now my branch full of merging which wasn't before i want to revert the git reset --soft HEAD~20 command how can it be done? Thanks!!

UPDATE
i did : git reset < commit hash before the reset: moving to HEAD~20 > then
git push and im getting :

error: failed to push some refs to 'https://xxxx@bitbucket.org/xxxx/xxxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
1 Answers

Run:

git reflog

It will show you something like this:

0475497 (HEAD -> master) HEAD@{0}: reset: moving to HEAD~20
ab155bc HEAD@{1}: commit: commit before reset
5da1f69 HEAD@{2}: commit: commit message
c2d9604 HEAD@{3}: commit: commit message
.
.
.

Then you can checkout or reset to the commit before reset, by using its commit hash ( in the above example, it's ab155bc )

Related