I did a rebase of my master branch but what I was expecting to happen didn't. It is probably a gap in my understanding so let me explain my setup:
I had the following branches:
4---O---X
/
3---O
/
2---O
/
1---O---O
/
O---O---N---O---O---O
When checked out on the 4th branch my site was running with every single change I had made in all the other branches including the master branch up to the point the 1st branch was created(N). As you can see I have added some more commits to the master branch after the 1st branch, so these were not available when on the last branch (or any branches except master).
I wanted to be able see the other commits on the last branch, keeping the branches as they currently are, so did a rebase of master so the tip of the 1st branch would be pointing to the end of the master branch like so:
4---O---X
/
3---O
/
2---O
/
1---O---O
/
O---O---N---O---O---O
I did this by checking out the 1st branch and doing rebase master. This appeared to work, but I do not see the later commits on master(past N), in the 4th branch. Which is what I thought would happen. I only see them in the 1st branch.
So my questions are why didn't the rebase work as I expected? and how to do I get the changes in master past the N point to show up in my 4th, 3rd and 2nd branches.
After rebasing 1 onto master, you will have to:
2 onto 13 onto 24 onto 3But since it's causing you troubles, alternatively, you could use a release branch where you can merge from all the branches you want to include in your release. Or, you could cherry pick from master into branch-4. Or you could merge from master into branch-4.
But I am afraid that if you want your graph to look like the one you show in your question, you have no alternative to the 4 rebase operations.
In general, to better understand how your commit graph looks like, try using:
$ git log --graph --oneline --all
Or better, try one of the git front-ends
If you rebase just branch 1, your new tree looks like this:
4---O---X
/
3---O
/
2---O
/
1---O---O
/
O---O---N---O---O---O
\
1'
1' is the tip of the rebased branch 1. So as you can see, the branches 2, 3 and 4 haven't changed with the rebase operation (which is correct, since you just rebased branch 1). If you only need the latest changes from master in branch 4, then it would be enough just to rebase branch 4 and keep the other 3 at the current state.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With