DEV Community 👩‍💻👨‍💻

Discussion on: ⛔ Squash commits considered harmful ⛔

xmarkclx profile image
Mark Lopez

One reason I'm for the squash merge camp hasn't been mentioned, so I think I should mention it here so @wesen can correct me.

We use squash merge to make it easy to revert a whole PR since it's just a commit.
It can be reverted after some time has passed easily by just reverting that commit.

What do you recommend for this so I can leave the wrong squash merge camp and follow the righteous path oh great @wesen .

wesen profile image
Manuel Odendahl Author

you can do exactly the same for a merge commit by using git revert -m1. The squash merge commit and the merge commit both point to the same tree hash, they only differ wrt the parent commits. With a squash merge, you only have 1, so git revert knows "ok well you just want to revert to the parent". With the merge commit, you have 2, so you have to tell it "please use the left parent (aka, the parent on the main branch) to revert to". easy peasy!