Yossarian Yossarian - 4 months ago 12
Git Question

git rebase already rebased branch

I have following structure:

F2: [F21] - [F22] - [F23]
/
F: [F1] - [F2] - [F3] - [F4] - [F5]
/
M: [M1]


And, I did squash (rebase) the commits in
F
branch, leading to following:

F2: [F1] - [F2] - [F3] - [F21] - [F22] - [F23]
/
M: [M1]
\
F: [F']


And merged to master:

F2: [F1] - [F2] - [F3] - [F21] - [F22] - [F23]
/
M: [M1] - [M2]
\ /
[F']


Now, I want to basically rebase
F2
to
F
, but that requires me to resolve conflicts along the path, mainly
F1
,
F2
,
F3
with
F'
. My desired result is:

F2: [F`] - [F21] - [F22] - [F23]
/
M: [M1] - [M2]
\ /
[F']


Is it possible to somehow hint rebase, that changes it is seeing are part of commits I have, so I don't need to resolve them?

Answer

The easiest way is to tell rebase to skip those commits with the --interactive flag. On F2, do:

git rebase --interactive [F']

You will see what git is preparing to do:

pick c411f13 F1    // <- delete this line or use drop instead of pick
pick 8f9b902 F2    // <- delete this line or use drop instead of pick
pick 7693586 F3    // <- delete this line or use drop instead of pick
pick 1fd0615 F21
pick 26fd795 F22
pick 2fb0408 F23

See the comments below these lines for more informations, # d, drop = remove commit and # If you remove a line here THAT COMMIT WILL BE LOST are interesting here.

Save and quit, git will do what you asked: skip the first commits and apply the others.