I have a git repo with a linear local history of, let’s say, 10 commits, where the first 5 is in branch1
‘s history, and the last 5 commits is in branch2
‘s history, and I want to fix the descriptions/author/date/other properties of these ten commits by amending them. The situation would be like this:
---(old history)---A--B--C--D--E--F--G--H--I--J
^ ^
| |
branch1 branch2
I’m not sure about how to proceed here. I can think of two strategies to do what I want to do, but I want to understand their potential effects first.
-
instead of doing a longer interactive rebase of 10 commits, I prefer to switch to
branch1
first, do an interactive rebase over its last 5 commits, and when I’m done, switch tobranch2
and do an interactive rebase of its last 5 commits. But since rebasing implies the creation of new commits in a “new branch”, I don’t know what would happen with the parent of the HEAD ofbranch1
. The question is, will that strategy create some sort of weird state like this (let’s callbranch1'
the new branch after the rebase):---(old history)---?--?--?--?--?--F--G--H--I--J | ^ ^ | | | | branch1(???) branch2(???) | | --A--B--C--D--E ^ | branch1'
or will git fix the parent of
F
in the right way? -
The other strategy is switching to
branch2
and do an interactive rebase of its last 10 commits directly; but, again, the question is, where will the HEAD ofbranch1
point to then after the rebase? To a commit that is not in thebranch2
history anymore?
3