6 ms·
My experience has been the opposite. Every organization I worked at used Trunk based development (feature branch->master). Because branches are short lived and
by tail_exchange 2y ago
My experience has been the opposite. Every organization I worked at used Trunk based development (feature branch->master). Because branches are short lived and usually small, they are the atomic representation of a change, and not the commits in the pull request. Pull requests usually have lots of "linting", "fixing test", "fixing typo" commits that I absolutely do not want in my master branch.
I understand that not all organizations work like this, but that is my point: there is nuance. Blanket statements like these are not productive. The author seems frustrated that people still use squash merge, and just assumes that it's because people just don't understand how git works.
- lucasoshiro 2y agoHi! Thanks for the comment! > My experience has been the opposite. Every organization I worked at used Trunk based development (feature branch->master). Each repository has its own necessities and you need to adapt the workflow to them. Sometimes for small repos what's work the best is commits on main, some people like the so-called "git flow", and Linux have different maintainers for each subsystem. > Because branches are short lived and usually small, they are the atomic representation of a change, and not the commits in the pull request. If they are small enough they can be a single commit. No problem in doing that, and the result will be similar to squashing. If they need more than one commit, so they are not exactly "small" > Pull requests usually have lots of "linting", "fixing test", "fixing typo" commits that I absolutely do not want in my master branch. I agree that if someone commits something and then commits a "lint", "fix typo", this could be solved in commit correctly once. But this is not always possible, so one can use the rewriting history tools that were mentioned. But I return the question: what are the downsides of having those commits? > Blanket statements like these are not productive. What, exactly, was blank? I tried to justify everything that I could based on the how Git works and debunk statements like "squash makes the history cleaner" (which, in fact, are blank). > just assumes that it's because people just don't understand how git works. So, I make the same question of the text: after reading and knowing what squash merges really are, what are the good reasons to still use them?
- DreaminDani 2y ago> what are the downsides of having those commits? In my experience, having to rebase on top of a branch with a lot of "lint" "quick fix" "let's try this" "oops, how about this" can be draining and sometimes lead to accidental code deletion. I like squash merges because I know it was the author's intended change that I'm merging or rebasing onto.
- kstenerud 2y agoYup, agreed. I've worked in orgs that use long lived branches and short lived branches... And short lived branches are by far less stressful to deal with if you can do it, precisely because of merge conflicts. Reality is never going to match your desire. Things are going to get messy, and so you end up with squashable commits among your commits that shouldn't be squashed. The branch you're merging should match your intent for atomic changes to the code that can be easily reasoned about when rebasing, merging, and bisecting. You write to history once, but you read from it many times. Therefore, optimize for reads.
- lucasoshiro 2y ago> In my experience, having to rebase on top of a branch with a lot of "lint" "quick fix" "let's try this" "oops, how about this" can be draining and sometimes lead to accidental code deletion. " But this is not always possible, so one can use the rewriting history tools that were mentioned." > I like squash merges because I know it was the author's intended change that I'm merging or rebasing onto. Can you elaborate, please?
- MartijnHols 2y agoThe poor commit quality is your issue here, and squashing is merely a way to avoid addressing it. That only makes squashing a good tool to use to make a big mess a slightly smaller mess.
- munksbeer 2y agoThank you, but no. I enjoy working on a branch and committing small changes at a time, sometimes trivial, sometimes not even compiling, sometimes formatting or whatever the hell I feel like. When it comes time to review, I squash all those trivial changes manually (rebase -i) and present a clean branch for review. We could try harder to enforce stricter policies on devs to ensure they're much more disciplined about their initial commits, but what we do works for us. It allows faster iteration and then we enforce squash and merge once ready to go to master. I don't understand why this bothers some people so much that they spend time ranting "you're using git wrong". If it was wrong, we'd be noticing and change our workflow. But it doesn't feel wrong, so we'll continue to use it.
- MartijnHols 2y agoInteractive rebasing away fixups in your branch is not squash merging. I agree that fixing a typo in a variable or a small linting issue in a previous (recent or not-pushed) commit in your branch is usually good. A carefully crafted commit history is all anyone can ask for. But then squashing away that history once the PR is merged would be a waste of a good history and the effort you put into it. If you end up squashing your history away anyway, why bother cleaning it up in an interactive rebase?
- munksbeer 2y agoI can't follow what you're saying. Once people start reviewing the PR, we typically do not manually squash (rebase -i) because it is helpful to see how the flow of the review went. Following this, we sometimes end up with 10 commits on a PR that are just addressing various comments, nitpicky or not. Then once approved, we click the "squash and merge" button, and github squashes all that useless noise into a single commit on master for us. We don't have any complaints about this workflow.