Merges vs. rebases and squashes #7726
Replies: 5 comments 22 replies
This comment was marked as off-topic.
This comment was marked as off-topic.
-
My stance here:
That said, I generally agree with the sentiment (regardless if it's doable at the time or not), but I just wanted to point out that,
^ this is AFAIK the unspoken norm right now. Maybe it's time to formalize it? Dunno, frankly. We have a lot of guideline in my corpo, and people just ignore them or not read them. Maybe it's worth it however to have them in one and easy to access place, or emphasize them more? I've been looking around and the only thing that comes when I search for "LMMS contribution guidelines" are https://lmms.io/get-involved & https://github.com/LMMS/lmms/wiki/Contributing-Step-by-Step , and maybe https://github.com/LMMS/lmms/wiki/Reviewing-Pull-Requests can be inferred... but some pages there should probably discuss this stuff, instead we have e.g. https://github.com/LMMS/lmms/wiki/Becoming-a-coder - while I really like what's written there, I don't think it answers many of the practical issues we have :D It doesn't even link to https://github.com/LMMS/lmms/wiki/Coding-conventions e.g. What do you think @tresf , is it worth it to try to get some additional codification of the rules or do a cleanup of the newcomer/guideline stuff? (and TBH I only found video "developer tutorials", no text ones, frankly?) |
Beta Was this translation helpful? Give feedback.
-
I haven't read the entire discussion but here's my 2¢: I know how much effort MG put into getting qt6 builds working, and to see all those work getting lost over a force push and then getting rewritten by another dev (tres in this case) is a bit too much for him. I would agree to remove all the trial commits but there's no need since we do a squash merge. Also removing trial commits shouldn't remove the actual working code. I would see this as a case of "the baby has been thrown out with the bath water" situation. I didn't try building qt6 branch after the force push as my activity got reduced due to college and I have minimized windows usage since. I could have caught this earlier but didn't because i was focusing on my college instead of lmms work. I am not against squashing but in this situation, there's more harm than good. |
Beta Was this translation helpful? Give feedback.
-
In my (now hidden) comment, despite criticism on this technique I've yet to see specific instructions to the contrary... Here's what I found: Here's a S.O. Q&A on the topic...
... one of the commenters was kind enough to share this atlassian article on the topic:
.. and another commenter shared this blog post:
As a frequent flyer of |
Beta Was this translation helpful? Give feedback.
-
I cannot agree to this. As a DevOp who works intensively with both Git and a painfully outdated "centralized VCS" (ClearCase), I am an expert for how much you can suffer if you cannot rewrite your history. Developers send an unordered mess of fixups to their reviewers, like
Also, if I combine the OP headings "don't do force pushes" and "don't do squashes" I get that you would either rebase+ff or merge-commit merge 50 or 100 fixup comments into master? That sounds totally wrong. In Git, a branch is not a "chain of commits", but solely a (movable) HEAD pointer. That means if you merge a branch into your branch, all the fixup comments are suddenly on master and appear in "git log", "gitk" and more (Imagine
When do I use what?
How to solve the problem with multiple authors?
Is an exact accreditation more important than a compact documentation, such that we merge commits un-squashed on master? IMO no. |
Beta Was this translation helpful? Give feedback.
-
Proposal to mostly use merges in development branches
I'd like to propose to use merges rather than rebases and squashes when working on development branches. The reason is that the history is maintained and that using merges is much less "dangerous" as it will not accidentally erase history or create potential problems in the working copies of other collaborators.
Just as an example what might go wrong with rebases/squashes: there was a specific case where a rebase was attempted which resulted in many commits being absorbed into one commit. I assume that it was rather a rebase followed by a squash which lead to this result. As a consequence all the changes done in individual commits by several people got squashed into the single commit which then was attributed to the person who did the rebase. IMO the history should be retained so that people can get credited for the work they did.
A better strategy would have been to merge master into the development branch instead of doing a rebase. In that case the commit history and the maintainers would have been kept intact. Even if the final merge would be done as a squash merge GitHub would still be able to credit all contributors in that merge because it can resolve the full history up to the final merge.
Rebases can also be dangerous because individual commits that might have built and worked before a rebase might not work build or work anymore after a rebase when all the commits are put on top of a new commit. This can create problems when doing git bisects.
Proposal to merge without squashing
I'd also like to discuss the current practice to do squash merges on all PRs when finally merging into master. As can be seen above one has to unnecessarily rely on GitHub to keep the credits and it can also hinder comprehending of how things came to be in the first place. This is especially true if the change set is rather large like for example with large collaborative PRs.
Keeping the history has other advantages as well. For example it's much easier to pinpoint a critical commit when doing a git bisect because the bisect can also search through the individual smaller commits. This can potentially make it much easier to find out the specific cause of a problem. With a squash merge the bisect might simply tell you the following at the end of the search: "The problem was introduced by the big wall of changes in this one large commit."
With regular merges it would also still be possible to just see the merges that are done in the direction of master. The following command for example shows the "clean" history of master without showing any commits from development branches:
It's also possible to show only the merge commits that have gone into master:
So I guess my proposal here is: "Squash merge small PRs if wanted/needed but keep the history of PRs with large change sets intact."
Don't do force pushes
It's generally advised to not use force pushes in shared branches/repositories because they rewrite history and can lead to all types of problems.
It should almost always be possible to for example integrate other branches with a merge commit so that the target branch can simply develop in a forward fashion without the need to rewrite history. All collaborators can then simply pull the new changes without running into conflicts because their repositories now deviate from the pushed state.
So I propose to not use force pushes, especially on branches that are worked on collaboratively and which include the work of many collaborators. Having to do a force push on such branches should be an indicator that something might be wrong and people should be aware of the risks. Force pushes should only be done if one absolutely knows what one is doing and in very isolated branches.
Edit: added the "force pushes" topic.
Edit 2: removed some personal aspects and elaborated a bit more on some general aspects.
Beta Was this translation helpful? Give feedback.
All reactions