Cleaning up branches before merging code on a team can be non-trivial. The goal of this gist is to discuss some of the common scenarios that occur as we are cleaning up our branch in preparation to merge.
In this scenario, imagine that we start with 2 branches: main
and a
. Branch a
has several commits that are not yet in main
. We branch off of a
to create branch b
. Branch a
is squash merged into main
, leaving b
with several commits that no longer need to be merged. When we are ready to merge b
, how do we avoid merging all of these commits?
- Squash merge
b
- When people review the PR, they will see all of the commits from
a
while reviewing. This leads to a less than desirable code review experience.
- When people review the PR, they will see all of the commits from
- Looking at the history of branch
b
in the future will be quite confusing.