Original:
A---B---C(master)
/
D---E---F---G(server)
/
H---I(client)
H, I are branched from the server branch, but do not depend on the server. The client has been completed. I want to extract H, I separately and merge it into the master, so I execute git rebase --onto master server client
and the result is:
A---B---C(master)---H---I(client)
/
D---E---F---G(server)
/
H---I
PS: Don’t think the example is strange, it comes from https://git-scm.com/book/en/v2/Git-Branching-Rebasing#More-Interesting-Rebases
The above is the rebase operation, using the merge operation, execute git merge --squash client master; git commit
, the result is:
A---B---C(master)---J(D+H+I)
/
D---E---F---G(server)
/
H---I(client)
Then the question is:
Is there any operation similar to git merge --squash server...client master
or git rebase --onto master server client --squash
? The effect is as follows:
A---B---C(master)---J(H+I)
/
D---E---F---G(server)
/
H---I(client)
PS: I know you can rebase --onto to the temp branch first, and then merge --squash to master, but this is too inelegant, isn't it?
There is an answer already. It is best to use rebase --interactive to mark squash, but I forgot about it:
or
Let’s see if you have any other ideas