I'm solving exercises over here:
We need to add commits H and I to your-master.
This is supposed to be the solution:
git rebase --onto your-master issue-555 rebase-complex
We're basically telling git to pick up all commits between issue-555 and rebase-complex branches and place them into your-master, isn't it?
Then this should have picked up G, F, E, H, and I in that order and placed them on top of D.
Why does this solution only pick up H and I but ignores E, F, and G?
CodePudding user response:
We're basically telling git to pick up all commits between issue-555 and rebase-complex branches and place them into your-master, isn't it?
No, we're telling Git to pick up all commits
- that are reachable from
rebase-complex
- except those that are reachable from
issue-555
.
Keep in mind that a commit is "reachable" only by walking in the direction of the arrows in your graph, not in the opposite direction.
You can think of it as a set operation:
- Take the set {A, B, E, H, I}
- and subtract from it the set {A, B, E, F, G}.
CodePudding user response:
pick up all commits between issue-555 and rebase-complex branches
No. There are no commits "between" those two things.
A commit is just the name of one commit. It happens that issue-555 is G, and rebase-complex is I. There is nothing "between" those.
Also rebasing does not move or "pick up" any commits. You cannot move a commit or alter a commit in any way. Rebasing copies commits.
Now think about reachability thru the parent chain. The expression issue-555 rebase-complex
means: Work your way back along the parent chain starting at I until you come to a commit whose parent is also reachable from G. Those are the commits to copy.
Well, that's H, because its parent E is reachable from G. So we copy everything from H thru I.