Live data from Hacker News

Two Years of Squash Merge (2019)

blog.dnsimple.com

11–20 of 194 posts

Re: Two Years of Squash Merge (2019)

#11
post #8
post #2

I will always fight tooth and nail against squash merge. Squash merge has the major disadvantage of getting rid of valuable meaningful git history. Squash merge is not the proper solution for keeping your git history clean, it is a hack using the side effect of squash. Keeping your git history clean is a matter of policy, best-practices and education: Developers should be required to submit _clean_ PRs, that is, PR's…

If only there was a way to have our cake and eat it too. I'm assuming there is because I'm assuming those squashed commits are floating somewhere in the reflog and somehow connected to the squashed commits in a way that should still let you bisect if only we had a tool to make it not suck. Alas, maybe someone with greater git-fu can inform us.

There are, as I answered separately:

`git log -p --first-parent`

Re: Two Years of Squash Merge (2019)

#12
post #8
post #2

I will always fight tooth and nail against squash merge. Squash merge has the major disadvantage of getting rid of valuable meaningful git history. Squash merge is not the proper solution for keeping your git history clean, it is a hack using the side effect of squash. Keeping your git history clean is a matter of policy, best-practices and education: Developers should be required to submit _clean_ PRs, that is, PR's…

If only there was a way to have our cake and eat it too. I'm assuming there is because I'm assuming those squashed commits are floating somewhere in the reflog and somehow connected to the squashed commits in a way that should still let you bisect if only we had a tool to make it not suck. Alas, maybe someone with greater git-fu can inform us.

In the article he says he keeps the original branch with all of the history around after they squash them with a reference to the original PR in the squashed merge commit message. So you can always just checkout the original branch and go digging in the full history.

Re: Two Years of Squash Merge (2019)

#13
My org has started to strongly recommend squashing before merging (in my opinion one step less extreme than the forced squash-merge mentioned in the article). I tend to consider this a decent principle in general but rules are made to be broken.

My main concern is if anyone ever commits based off of a pre-squashed branch. They won't be able to simply merge upstream after their parent has been squashed, they will now have to cherry-pick or incur strange redundant merge conflicts as they no longer share history.

For a small team whose features tend to be short-lived before going upstream this won't likely be a problem but believe me, if you ever need long-lived feature branches on a larger team, squashing them can cause more trouble than your nice history will gain.

Re: Two Years of Squash Merge (2019)

#14
Generally, time spent twiddling with the repo is time not spent delivering code. It's a distraction. Yes git has all these features that lets you do that and those feature matter when you're committing to the Linux repo which has thousands of eyes and your commit history has to help you communicate to a very wide audience. But the vast majority of us are not using git like this. I've used git bisect so rarely all this is overkill.

Re: Two Years of Squash Merge (2019)

#15
post #2

I will always fight tooth and nail against squash merge. Squash merge has the major disadvantage of getting rid of valuable meaningful git history. Squash merge is not the proper solution for keeping your git history clean, it is a hack using the side effect of squash. Keeping your git history clean is a matter of policy, best-practices and education: Developers should be required to submit _clean_ PRs, that is, PR's…

I would agree with your points if not for the fact that "clean up commits" or "typo fix" is a necessary result of PR's. Your teammate will request changes in your code, and the only way to cleanly communicate "yes I made that change, and ONLY that change" is through these clean-up commits. Otherwise, if you amend/force-push or open an entirely new PR, 99% of the diff are things that your team has already seen and rev…

> Otherwise, if you amend/force-push or open an entirely new PR, 99% of the diff are things that your team has already seen and reviewed.

gerrit has solved this issue for years by showing the diffs between each successive revision of a patch.

e.g. look here the files at different origin patchsets : https://codereview.qt-project.org/c/qt/qtwayland/+/321246/3....

Re: Two Years of Squash Merge (2019)

#16
post #2

I will always fight tooth and nail against squash merge. Squash merge has the major disadvantage of getting rid of valuable meaningful git history. Squash merge is not the proper solution for keeping your git history clean, it is a hack using the side effect of squash. Keeping your git history clean is a matter of policy, best-practices and education: Developers should be required to submit _clean_ PRs, that is, PR's…

> Developers should be required to submit _clean_ PRs, that is, PR's whose git history has been organized and refactored in such a way that it removed "clean up commits", "typo fix", etc. A complete and utter waste of time. You spend more time messing about with rebase than solving problems. When you're digging through VCS history due to a bug you often ignore the commit message anyway - if the code did what it seeme…

Could not agree more...I wish I had more of substance to add, but an upvote didn't feel sufficient

Re: Two Years of Squash Merge (2019)

#17
Squash & merge is objectively worse than rebase && merge --no-ff.¹ (Roughly what the article calls "no fast-forward".) "No fast-forward" meets all of the criteria the article's author proposes:

> 1. Combines all the code changes related to a single logical change

Yes: the merge commit is that.

> 2. Provides an explanatory commit message that helps people understand the intent of the change

This is no more or less true that squash & merge. (Although, I don't off the top of my head remember how good the automatic message in Github is.) But that's more a problem of an automatic message than it is the merge strategy, & squash and merge also has this. (I've seen numerous squash commits with "Fix CI, Fix CI, Code formatting, Fix Lint warning" in them…

Good commit messages boils down to the discipline of the coder. (And a reviewer being able to say, "Can you write a better commit message?".)

> 3. If you pick this commit independently from the history, it makes sense on its own

The merge commit.

What you lose with squash & merge is the history. The author does sort of address this:

> In case you are wondering if we are losing the individual changes, the answer is no. Each squash merge references back to a PR where the whole changes are tracked:

And while this is technically true, it's a reference only in the textual message (which Github will nicely turn into a link, but you must be in Github for that). "No fast-forward" will maintain those references in the git commit parent information, which means that tooling like git bisect should be able to see into it. But with a squashed commit, the closest you get is "some commit in this PR", essentially. Same with reverts: if just one commit on a feature branch is bad, you can simply revert that one commit. (Or, if most of the branch is bad, you can revert the merge commit & cherry-pick the good bits.)

If you don't want to see all the feature branch commits in the history, you can just follow first parents.

¹I prefer a quick rebase prior to merge but after code-review, as it is a good balance between the resulting history being readable, and not rewriting history while your reviewer is looking at it. But the argument here should hold regardless; the definition the article uses is sufficient, too.

Re: Two Years of Squash Merge (2019)

#18

Earlier quoted context omitted.

I would agree with your points if not for the fact that "clean up commits" or "typo fix" is a necessary result of PR's. Your teammate will request changes in your code, and the only way to cleanly communicate "yes I made that change, and ONLY that change" is through these clean-up commits. Otherwise, if you amend/force-push or open an entirely new PR, 99% of the diff are things that your team has already seen and rev…

> Otherwise, if you amend/force-push or open an entirely new PR, 99% of the diff are things that your team has already seen and reviewed. gerrit has solved this issue for years by showing the diffs between each successive revision of a patch. e.g. look here the files at different origin patchsets : https://codereview.qt-project.org/c/qt/qtwayland/+/321246/3....

This was a feature of ReviewBoard as well. The history of code review changes was maintained by the tool separately from commit history.

Re: Two Years of Squash Merge (2019)

#19
post #6
post #2

I will always fight tooth and nail against squash merge. Squash merge has the major disadvantage of getting rid of valuable meaningful git history. Squash merge is not the proper solution for keeping your git history clean, it is a hack using the side effect of squash. Keeping your git history clean is a matter of policy, best-practices and education: Developers should be required to submit _clean_ PRs, that is, PR's…

maybe its not 100% one way or the other? I love squash for somethings, but not others today I brought in one big merge, 20+ commits , so don't squash it. but I also have 20 "little fix" branches, with 1,2 commits each which I merge all together and squash in as one merge to main.

This is exactly how i run my project.

Amazing that folks get into these "two sides" debate. The reality is always a grey area. And you should be flexible enough to see the benefits of the different variations. With some guidelines on how to make a decision.

Re: Two Years of Squash Merge (2019)

#20
post #2

I will always fight tooth and nail against squash merge. Squash merge has the major disadvantage of getting rid of valuable meaningful git history. Squash merge is not the proper solution for keeping your git history clean, it is a hack using the side effect of squash. Keeping your git history clean is a matter of policy, best-practices and education: Developers should be required to submit _clean_ PRs, that is, PR's…

> Squash merge has the major disadvantage of getting rid of valuable meaningful git history.

I think the main point of the article is that the Git history is often *not* valuable (because it's hard to enforce good commit messages). Your later points are very valid, however, and that's why I argue for smaller pull requests (and never merging a PR into main that leaves it in a broken state).

Post reply on HN