Reputation: 1400
My current branches look like:
D
/
H--A--B--C
I was trying to work out how to produce a new git branch which would make the new git repo to looks something like:
D
/
H--A--B--C
\
C
Is this possible to do? I thought about using reset but that would mean changes from C would also be lost, so looking for an alternative.
Upvotes: 1
Views: 102
Reputation: 1400
OK so found a way to do this.
I created a new branch with A in it:
git branch new-branch <A sha1>
Then I used cherry pick to merge C with A in the new-branch:
git checkout new-branch
git cherry-pick <C sha1>
And that made the repo with the branches I needed.
Upvotes: 5
Reputation: 30414
C A--D
/ /
A*--D H--A--B--C
/ \
H--A--B--C A--C
(1) (2)
Because (1)
is an equivalent if (2)
you can just git checkout <commit sha1 of A*> -b your-new-branch
Upvotes: 0