I've encountered a workflow on a new team I'm a little unfamiliar with. The goal for most pull/merge requests is to have a single, squashed commit, in an effort to have a clean history.
That is fine and well, as usually the squash commits occur once a PR has been tentatively accepted (to be merged once squashed and push --force
ed). Thus, working from the develop
branch is usually safe.
However, I have a conceptual problem with this strategy when branching work from a commit with a high likelihood of being re-written. This diagram illustrates current and desired states for such a scenario.
- Work is completed on
feature/foo
and is squashed in preparation for peer review - Work begins on
feature/bar
(branched from commitA
) - WIP commits are added (
E
&F
) - Peer review reveals minor changes which are added to the Pull Request (commits
B
&C
- Pull Request is approved, pending squash commit
- Branch
feature/foo
is squashed and re-written to commitD
This is where I'm unsure how to proceed. My question is how can I best "replace" the ancestor of branch feature/bar
? Some solutions that come to mind are branching off of the new squash commit (D
) and cherry picking F..E
and then overwriting (deleting and re-checking out) branch feature/bar
. Is there a better solution to this i.e. using rebase
?