문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

    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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top