Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
DOC: Update policy to prefer squash merging#28821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -228,11 +228,14 @@ unsure why a test is failing, ask on the PR or in our :ref:`communication-channe | ||
Number of commits and squashing | ||
------------------------------- | ||
* The default and preferred method of merging code into the main branch | ||
is to squash merge commits so that a single clean and usable | ||
commit is in the git history. The commit message should be cleaned up | ||
by the person merging so that the git history has useful messages | ||
when going through the history. If the commits are organized and contain | ||
useful messages, the PR author can ask the person merging to not squash | ||
the commits. This is done on a case-by-case basis and at the discretion | ||
Comment on lines +235 to +237 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. If the commits are organised and contain useful messages, does the author need to actively state they prefer their commits aren't squashed? It seems implied by the fact that they kept their commits in order. I think people who prefer that will mostly be our maintainers - who are a minority of contributors but account for a majority of PRs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I'm always curious about this argument. Does anyone really care if the commits are "organized"? What do people do with that organization? Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I care when trying to understand why code is written the way it is or since when. Using git blame gives you the commit that a line was changed. It's very helpful then if all related change is in the same commit and all unrelated change is not. Answering@rcomer's question: Generally, if multiple commits look reasonable (*), we can keep them, no matter if the author stated that explicitly. This may very well happen for experienced non-core devs. They know how to structure compex topics over multiple commits, but may not be aware of our policies. (*) Reasonable is to a certain extend in the eye of the beholder. One can easily identify the extremes. OTOH, I would not squash commits from other people if they are very clear. I would squash the "small" PRs with many trival commits. If I the PR is too large / touching multiple topics, and I have the feeling it should be split up, I'd ask the author to reorganize - this is likely even necessary for simpler review. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Sure it's good to have reasonable commit histories. I'm just curious why folks would bother being overly meticulous with this. If a change is made in boo.py I'm not too likely to be confused by the blame if a change is also made in doc_boo.rst But I'm fine if the merger wants to make a judgement call. I guess if in doubt ask. I think 99% of PRs a squash is fine and saves a step as noted in the original justification There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Some people just prefer that their own PRs are not squash-merged. I personally do quite like the fact that I can do
and it will tell me which of my branches can be safely deleted. That won't work any more if the branches are squash-merged. That said, this is just a preference, not a hill I'm going to die on. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
Eek, that's the only way things get cleaned for me. I think, like most maintainers, I just do my own rebase squash/plan to get to it after the final round of reviews. Or usually I've done something like tweak css/.toml/conf.py b/c of the PR but unrelated enough that I'll keep it in a separate commit for history/bisecting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The reason for changing to squash-merge was so that we don't require more inexperienced authors to squash themselves. Wecould have a case-dependent policy: Stick with simple merge, but squash-merge if the PR commit(s) are not well organized. I think one can usually tell the difference (or ask if not). The downside is that we put the burden on reviewers and they have to select the strategy case-by-case - GitHub UI keeps the last used strategy as default and you'd have to go through the dropdown. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
I think yes. I don't think it should be on the person merging to consider "oh this person wants X, this person wants Y".
I think that the bottom line of my thinking is that if someone chooses one method or the other, the author should not be upset about it. If someone wanted their commits kept, but they get squashed then 🤷 Make a small PR for each individual change instead with a single commit each which will guarantee those commits get kept separately. Regarding removing local merged branches: Rather than checking if a branch wasmerged, I check if a branch exists on my remote. So after someone merges, I click the "delete branch" button, which then deletes it from my There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Keeping your local repo clean is an interesting use case of keeping commits the same. However after a merge I typically delete the branch on GitHub and then it's not on my "origin" remote. I treat my local repo as ephemeral. | ||
of the person merging. | ||
* Do not let perfect be the enemy of the good, particularly for | ||
documentation or example PRs. If you find yourself making many | ||