Klaus
Klaus

Reputation: 25613

git: how to deal with to early branching

I did something like:

          y1-y2-y3-y4-y5
         /          /
x1-x2-x3           /
         \        /
          z1-z2-z3

But now I want to have changes from y1 and y2 also in z2 and the the next ones.

z3 was already merged into y5.

What we want to achieve is something like:

         y1-y2-y3-y4-...- throw away
         /   \       
x1-x2-x3       \    
         \       \ 
          z1-z2-z3-z4- continue work with changes from y1&y2

How to deal with that problem?

  1. cherry pick
  2. on z3: git merge y2? ( on z3 merge seems to work. )
  3. something else

Some additional info:

The repo exists on 3 servers. ( No permanent network excess possible ) Each clone access all remotes from time to time. In case of using rebase I fear of some side effects.

Upvotes: 2

Views: 87

Answers (1)

exussum
exussum

Reputation: 18550

The rebase command was actually base for this.

Currently your branch is based at x3 and you want to move its base to y2 so

git checkout z 
git rebase y2

https://git-scm.com/book/en/v2/Git-Branching-Rebasing

For more examples

Upvotes: 1

Related Questions