I have merged two branches. Now it seems that I had to rebase the two branches. What should I do? Here is what I am looking for
How to convert a git merger into a rebase
1.7k views Asked by odbhut.shei.chhele At
2
There are 2 answers
2
On
You can just reset your branch to the point before the merge and then perform a rebase instead. So if this is your situation:
experiment
↓
A --- B --- C --- D --- E
/ \
* --- * --- * ----- X ----- M
↑
master
Then reset master
to commit X
, and then perform the rebase on experiment:
git checkout master
git reset --hard X
git checkout experiment
git rebase master
Then you will end up with this:
* -- * -- * -- X -- A' -- B' -- C' -- D' -- E'
↑ ↑
master experiment
So the merge commit M
is gone and your experiment branch is rebased onto master
. You can then fast-forward master and get rid of the experiement branch.
If you are on the develop branch:
Revert the merge:
Go to experiment branch:
Perform the rebase: