I\'m trying to script rebasing and my script will take different paths depending on if the rebase results in any conflicts.
Is there a way to determine if a rebase w
You still can do git rebase, play with it as you want, than recover all the changes from before.
Assuming you have done your rebase of some branch into the master
, and you don't like it:
git reflog -20
- gives you last 20 positions of your HEAD with a little descriptiongit checkout
- places your HEAD on the branchgit reset --hard
- places your HEAD and branch on the old ref, this way you can recover old branch.There are some mechanics to understand here:
rebase
and your other on HEAD manipulations is written in the reflog
@{N}
annotations from reflog
So, nothing is lost after the rebase
, you just have to know how to find and recover it.
For example you can place yourself a tag before the rebase
than revert to it or delete it. it evades you all the SHA1 research step.