Reputation: 801
I merged my development branch into my master branch and have made many changes since then. How could re-split the dev branch from the main branch and maintain the changes.
master -------merged -------changes -- mstr & dev ------need to split ----master
dev------------^ \------------- dev
Upvotes: 1
Views: 416
Reputation: 14071
From your description you want to (figuratively) move your 'master' branch back to the point just before you did the the merge, and you want your current development work to be on your 'development' branch.
If I understand your desire correctly, that is essentially a swap of the two branch pointers, with a tweak to ensure you aren't pointing at the merge commit itself.
On master, use git branch --move master new_develop
to rename master to the new name.
Then assuming your old development branch is pointing at that old merge commit (check this gitk development
), use git branch master development^2
to recreate master but at the 2nd parent of the development merge (note the swapped argument order).
Finally, git branch --move new_develop development
to bring back your old branch name. Check it all with gitk
or your favourite tool.
Upvotes: 0
Reputation: 1327264
If you continued development on your dev
branch and on master
, you simply need to rebase dev
on top of master
:
First, you merged dev
to master
:
x--x--x--x---X (master)
\ /
y--y--y--y (dev)
Then you make evolutions, on dev
and master
:
x--x--x--x---X--x--x (master)
\ /
y--y--y--y1--z--z (dev)
How could re-split the dev branch from the main branch and maintain the changes.
git checkout dev
git rebase --onto master y1 dev
You could try a git rebase -p
, for preserving merge commit, but in your case, simply rebasing the part which interests you, the 'z
' commits, is simpler.
x--x--x--x---X--x--x (master)
\ / \
y--y--y--y z'--z' (dev rebased)
Upvotes: 2