About Squash & Merge

Suppose we have the following chain-like branches:
Branch main -> Branch dev1 -> Branch dev2.

After branch dev1 is squash&merged into main, when try to merge dev2 into main, the diff includes all the diffs in dev1. To merge dev2 into main, I have to merge main into dev2 first.
However if dev1 is merged into main instead of squash&merged, there won’t be any problem, and diff between dev2 and main is automatically updated.

I wonder is it possible to make squash&merge have the same behavior as merge in this chain-branch situation?

I’m afraid there’s not, what you’ve described is exactly why you shouldn’t use squash&merge in interconnected branches. It works fine if you develop a feature on a branch and then squash the intermediate commits on merge, but for anything more complex it causes trouble because it changes history.

1 Like