4 ms·
Hi! Thanks for the comment! > My experience has been the opposite. Every organization I worked at used Trunk based development (feature branch->master). Each
by lucasoshiro 2y ago
Hi! 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?