Regulations in my industry require strict linear development - therefore no merge commits in master. We also cannot lose authorship, so extreme squashing of commits is difficult. We've spent a lot of time exploring options for maintaining features in branches and have hit a lot of speed bumps. I will summarize the solutions we've tried and the issues we've found with them. I also have an idea for a solution that I would love help fleshing out.
Solutions:
Feature branches are regularly rebased onto the tip of master. No squashing.
Drawbacks: Merge conflicts are resolved per commit. Time cost is high as feature branch grows large.
For example say commit A changes a file significantly, so you resolve a bunch of merge conflicts, then commit B reverts some changes and makes some more changes, so a bunch of those merge resolutions never really needed to happen. Finally commit C deletes the whole file and everything was a complete waste of time
Feature branches are merged regularly. At the end of the release a soft reset to master is used to merge all changes.
- Drawbacks: Hit by regulations. Authorship of code must be maintained.
(Unattempted) Feature branches are merged regularly. Fancy git tools allow us to imperfectly convert this branch into a rebase style branch at integration time.
Idea: Say we have a branch feature/branch that is our "merge style" branch and we want it to be a "rebase style" branch on top of master. We then follow something similar to these steps:
Get a list of all commits in feature/branch that are not in master using
git log --pretty=format:%H %p --reverse feature/branch ^master
Do some text parsing on that list to get a list of cherry-pick commands
git cherry-pick <hash> -X theirs
(merge commits would have the argument-m #
-- I'm not yet sure of which is better forours
vstheirs
or which number is best for the-m #
command )Run this list as a batch file on master. This gets us to a point of having possibly sufficient history of authorship.
Checkout features/branch and perform a soft reset to the modified local master. Check all of these changes into the tip of master to get master to a good state.
I'm currently stuck on step 3. Even with either strategy ours or theirs, I still get merge conflicts. I imagine I was being overly optimistic to expect the strategy to magically force a cherry-pick.
I'd really appreciate any feedback on the proposed solution - even if it's to ridicule it - and I'd love to hear any new ideas for managing this workflow.