When developing on a long-running branch (here defined as living longer than one release), what's the most accepted practice(s) to keeping the branch current with its origin while keeping the history relatively clean prior to merging back?
As an example, consider the origin branch (m
) and a (topic) branch (t
) with the following history graph:
A[1]--------F[2]--H[3]--J[4] (m)
\ \ \
B----C-D-E--G-----I-----K (t)
[1] - Release 1.0
[2] - Release 2.0
[3] - Hotfix 2.1
[4] - Hotfix 2.2
In branch t
I've been merging from master (m
) periodically to keep my topic branch up to date, but there are many small commits between B
and K
that I'd like to squash with a rebase.
I'm concerned if I squash those commits that I will change the hash of the merged commits from master and create problems for others when I merge my branch back into master for Release 3.0.
If I rebase -i
the topic branch, I expect the graph would look like this:
A---------F---H---J (m)
\
B-----------------K (t)
where K
contains all the squashed commits between B
and K
including the merged changes from master (F
and H
). If I then merge t
back to master m
I'm wondering if there likely be conflicts from F
and H
. The graph should look like this then:
A---------F---H---J---L (m)
\ /
B-----------------K (t)
t
can now be deleted because it's no longer used. I'd like to keep the history of where t
was branched from, so rebasing B
onto J
would lose that information and probably solve my problem but the graph would look like:
A---------F---H---J---K' (m)
Is this a valid concern? What is the commonly-accepted practice to keep one's feature branch current with its origin while keeping a relatively clean history?
Note: the example here is simplified, there are actually hundreds of commits from the branch point to HEAD on the topic branch - over 300 - many of which could be squashed out of existence
--no-ff
option.