In Git, how do I detach a branch from its upstream branch?
I have a branch that was built from another branch, but should actually be a separate branch from master (they are great features). Right now I believe I have this:
...- master
\
A1 - A2
\
B1
I want none of the changes on branch A to be on branch B. The result should be:
B1
/
...-master
\
A1 - A2
So far I've tried git branch --set-upstream-to=master
and git rebase master
(so far on B), but that doesn't do what I want.
+3
Michael Winterstein
source
to share
2 answers
It should be rebase --onto
:
git checkout B1
git rebase --onto master A2 B1
+3
VonC
source
to share
one way might be to create new branch from master and cherry as well - select commits made on B1
git checkout master
git checkout -b B1 #(either delete beforehand B1 (git branch -D B1) or use a different name here)
git cherry-pick SHA-Commit-on-B1
...
since cherry-pick supports a range of commits, see fooobar.com/questions/4321 / ... it might be worth a try too
0
jethroo
source
to share