Undoing a git rebase
An explanation for git rebase
Here we will find a way of undoing a git rebase. So the simple way of doing this will be to find the head commit of the branch. As it was immediately before the rebase started in the reflog…
git reflog
If you want to reset your current branch to it you should use the following:
And Suppose that the old commit was HEAD@{2}
in the previous ref log:
git reset --hard HEAD@{2}
So if you are using windows so have to quote the reference:
git reset --hard "HEAD@{2}"
Also one can check the candidate history old head by just doing a git log HEAD@{2}
If you’re not disabled per branch reflogs you should be able to simply do git reflog branchname@{1}
as a rebase detaches the branch head before reattaching to the final head.
And for non bare repositories by default, all reflogs are activated
[core]
logAllRefUpdates = true
Also read, Why are these datagrams reassembled to a single datagram