I am working on a branch (with others) off of master.
A - B - C - F - G (master)
\
D - E (branch-a)
Periodically, we merge master into the branch, to minimize conflicts later.
A - B - C - F - G (master)
\ \
D - E - H (branch-a)
Eventually, we will want to merge back.
A - B - C - F - G - I - K - M - N (master)
\ \ \ /
D - E - H - J - L - O (branch-a)
What is the cleanest way I can merge back into master?
- I want to preserve the individual commits (i.e. no squash)
- I will not use
branch-a
any longer, so commits hashes can change. - I would like to not include merge commits (e.g.
H
,L
) for merges without conflicts, if possible.
Ideally, it would look like this (assuming there were no conflicts):
A - B - C - F - G - I - K - M - N (master)
\ /
D - E - J - O
Any ideas on how this should be done?
(FYI, this is a question about my workflow. If I should have done something else earlier, that is a legitimate answer too.)
UPDATE:
After thinking about this some more, I realized this is often not possible.
For example, if J
changed a line that G
changed, there would not be a way to get that history.
The next best choice would be to have this history:
A - B - C - F - G - I - K - M - D - E - J - O (master)
Essentially, this is a rebase, but omitting unnecessary merge commits.