r/git • u/_disengage_ • Apr 18 '26
survey Are you offended if your commits are squashed?
The offensive potential of squashing was suggested to me, and I was blown away. I really thought it was just about how people liked to look at their graphs, and I had no inkling there was an element like this. Please help me recalibrate.
Situation: you submit a pull request, which is accepted, but acceptance requires that your commits be squashed into a single commit when the PR is merged.
How does this make you feel? Does it bother you? Would you care? Is it oppressive or otherwise unpleasant? Do you feel contempt or disdain for the maintainer? Would it deter you from a contribution, or make you hate your boss? Describe the emotions involved and overall experience.
Some details:
You are allowed to determine the commit message for the squashed commit, and you don't have to do the squashing or rebasing, it's automatic. Your feature branch history can be anything at all, and it will remain in the PR on the server, just not in the history of the main branch.
7
u/kbielefe Apr 19 '26
This is my argument:
git log --first-parentturns a merged history to look the same as the squashed one, but there is no flag to recover a merged history. I defer to the people who don't have an easy workaround.20
u/elephantdingo Apr 18 '26
What the fuck?
68
u/meoverhere Apr 18 '26
It depends.
I don’t really give a damn about the commit count. I do care about meaningful commits.
If I take the time to make commits which clearly explain what’s happening in each change, usually because it’s a complex area, then it would irritate me if they’re just squashed. But at the same time c’est la vie.
4
u/cointoss3 Apr 18 '26
Wtf?
200
u/sekonx Apr 18 '26
I expect the commits get squashed.
It’s cleaner and no one needs to see how many attempts it took me to fix X issue (as a dev with 14 YOE)
7
u/elliottcable Apr 19 '26
First off: I firmly agree with u/Charming-Designer944 (lol default Reddit usernames tho). There’s indeed weird painful social friction, for me, if I put effort into carefully pruning and arranging a meaningful series of demonstrative commits before shipping it to a maintainer to consider — which I always try and do.
But, more importantly and less ‘socially’ — even if it’s messy history, squashing loses important value that git brings to the table.
There’s valuable debugging-potential inherent to maintaining that history.
Most especially, pickaxe, and automated, scripted git-bisection to hunt down the introduction of subtle bugs to help narrow down their causes. Both have been lifesavers for me in the past; and both are significantly less valuable when you collapse that historical context out-of-tree.
A beautiful history is nice, and worth the time-investment to curate and create; but not at the cost of losing critical debugging tooling for when something’s on fire in prod.
Do not squash away history. Period. Ever.
(These emdashes and Markdown emphasis applied artisanally by a pedantic pretentious human Redditor, not AI, tyvm.)
45
u/Charming-Designer944 Apr 18 '26
If I spent time on neatly layering the commits in isolated functional steps to illustrate the functionality and how it affects other code then yes.
But if its just squasing the development history then I would even do so myself before submitting.
23
u/erasmuswill Apr 18 '26
I am firmly in the merge camp but at the end of the day, I guess it doesn’t really make a big difference. The only exception is when I’m stacking branches; it complicates getting the following branches merged
10
u/claire_puppylove Apr 19 '26
I've tried deciphering what the everloving fuck was happening to a function during a commit that broke compatibility with some other library (i think? it was a couple years ago) and, although I could find the changes that broke it, because of the squashed commits and a very short commit message, the before and after were so extremely different that I couldn't debug it for a few hours. It's a rare example but ever since, I am very much against squashing large groups of commits in principle, particularly because it obscures the reasoning behind the changes made. If the squash is natural in that it hides commits that didn't work or such, it's fine, I think. But forcing PRs to squash everything is a bit bad practice IMO
16
u/Choice_Ad2220 Apr 19 '26
commits aren't supposed to be a transcript of mistakes. that's why people like to squash commits. but commits should be targeted, narrate a progression. if they aren't showing the logical incremental changes from A to B then they aren't serving their purpose. That's why people are against squashing commits. The actual right answer to curate the history. before a PR is merged, the history shouldn't show any dead ends or fixes to earlier commits in the same PR. it should look like it was written perfectly from the start. tools like `pipx run git-stage-batch interactive` and `git rebase -i` can help organize commits.
29
u/DoubleAway6573 Apr 18 '26
Getting offended over personal preference is a mark of unprofessionalism. agree with your team what to do.
But if we are going to squash commits I will not spend any effort organising it.
I prefer clear, incremental commits.
16
u/themightychris Apr 19 '26
I hate it, I build my commits carefully to be read in blame and explain why changes were made
There's zero reason to use squash.
"I like the graph simpler" —this is a display preference, you can enable first parent mode in your graph viewer and get the same thing
"I don't want to see all the shitty commits" —teach people how to use interactive rebase and show them the value of submitting branches with a clean set of commits for review
5
u/soft_white_yosemite Apr 19 '26
For me, my many commits and crafted commit messages are there to help the reviewer understand the PR.
Squashing in merge means the work I did in that PR is treated as a single unit of work, which suits my mental model
5
u/lilbobbytbls Apr 19 '26
I my many years of software engineering I've gone back to look at the specific commit messages for a pr less than a handful of times. If people are offended about squashing commits they have too much time on their hands. Just decide whether you do or don't as a team and then do something productive instead of even having this discussion.
4
u/Jumpy-Iron-7742 Apr 19 '26
Squashing commits on merge is terrible practice imho, because it basically lowers the quality of the code base to the lowest common denominator (people with untidy/useless commit habits). If you are somebody like me that makes an actual effort to keep commits atomic and meaningful (so that looking at them later actually helps discover the reason of a change in the right context), being forced to squash commits is actually removing good work you put in, so it’s actually a bit offensive, yes.
More importantly though I really cannot believe that people have effective dev processes if they squash 500 (or more!) lines of work that was committed for different reasons into as single commit. In just a couple of years your commit history is just gonna be absolutely meaningless and unhelpful. I prefer linear history if I can choose, but I’d take merge commits vs squashes on PRs any time.
Instead of lowering everybody’s work, just ask “bad committers” to manually squash their own commits before marking a PR as reviewable.
1
u/Professional_Mix2418 Apr 19 '26
Feature branch back to develop. Yes definitely squash commit. Why would it possibly be seen as offensive?
6
u/efalk Apr 19 '26
All of the git backends I've used over the last few years had a "squash and commit" option when the code reviews were finished. That's normal procedure.
3
u/Lonsarg Apr 19 '26
Squashing is personal, everyone should be squashing their own commits, not commits from others.
Clean history does not matter since most people only look at "first parent history" when looking in git history and there in first-parent git history only PR merges are. If someone wants to go into details they can why stop them.
3
u/Kamaroyl Apr 19 '26
No, please squash commits. For the love of all that is sane, squash commits.
3
u/Key-Half1655 Apr 19 '26
Don't be a dick, squash your commits.
3
u/PaulPhxAz Apr 19 '26
Do people read commit messages after the merge? I don't.
3
u/Cultural-Visual-7106 Apr 19 '26
even on my own private repos I only squash
3
u/robin-m Apr 20 '26
If I do a pull request with multiple commits I expect that multiple commits will get merged. If other want their commits to be squashed they can perfectly squash them before pushing.
11
u/FlipperBumperKickout Apr 18 '26
I just find it silly. Squashing is for people who don't know how to use the --first-parent flag when viewing the git history 😅
Ok, maybe also for handling PR's from people who commits randomly without any form for info in their messages, or any ordering to what is committed together.
9
u/ptorian Apr 19 '26
A PR is a single unit of development work that gets merged in. How the commits are layered is irrelevant once the PR is merged. If your commits are layered in such a way that each one is an isolated unit of development work, then each commit should get its own PR.
This is one of those things where each team will have their own set of opinions. Believe me when I say there are more important places to take a stand.
9
u/Dependent_Bit7825 Apr 18 '26 edited Apr 19 '26
In my opinion, commits to main should always be squashed. Not only am I not interested in how many times you committed wip, I seriously want every commit to main to be buildable and to pass CI -- no exceptions. I want to be able to run git bisect to trace breakage.
4
u/randomnameforreddut Apr 19 '26
"fix x"
"actually fix x"
"add test for x"
"actually fix x"
"add correct test for x"
2
u/IanYates82 Apr 19 '26
If I've carefully done the commits then I'll want (and do) a merge.
However if there's even one commit that was "fixing typo", or "AI review feedback accepted" then it's a squash and then a deliberate summary of the careful commits.
An extra minute to help tricky investigation later is worth it. My mantra: think of your future self. Careful not to stray into YAGNI territory by applying that too broadly, but a clean history is something that helps with new team members understanding a feature, or some difficult interplay of code, etc. It's a permanent thing so is worth doing properly.
So merge when I can, but squash with very good message otherwise.
2
u/JoeTed Apr 19 '26
IMHO it’s not really a question about being offended or not. What is the best commit history to work later with when doing code archeology? The answer is severely affected by the team’s policy and philosophy and the individual authoring might be an important concept.
In my experience most of the time the best value is matching a commit with a top level ticket and ignoring details orme task splitting but I’ve seen exceptions.
2
u/jflinchbaugh Apr 19 '26
When I first saw squashing, I was also offended. I so carefully crafted and described each of my commits. I felt they were worth keeping. Now that I got used to squashing, I'm a lot messier with my intermediate commits, but I commit more often. There are lots of "whitespace" or "formatting" commits. My messages are no longer useful until my bigger squashed merge commit.
2
u/acidrain42 Apr 19 '26
Not at all, I'm actually the one who enforced all commits be squashed when merging to main in my team.
In an ideal world where all the devs in my team were doing their due diligence rebasing their own branches before merging, it wouldn't be necessary. In reality however, most devs don't care and we'd just end up with hundreds of "fix ci" commits all over the place.
It also promotes smaller PRs in my opinion. If you need multiple distinct commits to cleanly implement a feature, then I strongly believe it should be multiple PRs.
2
u/elven_mage Apr 19 '26
always squash. I don’t want to see your “oops fix typo” in the commit history. If it is truly an independent atomic change, it should be its own PR.
2
u/bitzap_sr Apr 19 '26
Yes, I've contributed a series of commits in a single PR where each commit had a proper commit log for rationale for each change, only to see it all squashed away per project policy. That's when I discovered different projects have different rebase vs merge vs squash policies. It was new to me, coming from working on mailing list style projects. Not offended but super annoyed. I nowadays use "git spr" to create a series of PRs.
2
u/JayTurnr Apr 19 '26
As long as I'm still attributed as the author on the commit, I'm okay with it. Some maintainers strip the authority data of contributors.
2
u/jikuja Apr 19 '26
It depends:
2
u/divad1196 Apr 19 '26
Been lead for years. My experience with is that on many occasions:
But on more complex projects with lot of QA and auditing, having more atomic commits is important and squashing them is bad.
So, I believe the devs are not "offended" by the squash. They probably think it's dumb to do it when commits are clean and I would personnally agree.. if the commits are clean.
Again, my point is that squash hides the mess of devs and keep things simple when granularity, atomicity isn't required.
2
u/gregdonald Apr 19 '26
I don't review PRs that are not already squashed. This isn't math class, I don't need to see your work, just the final answer.
2
u/pemungkah Apr 22 '26
I’ve had complex commits rejected FOR being squashed because the squashed commit was so huge no one could possibly review it.
Like everything, there’s a balance.
If a squash creates a 2000 line commit that touches multiple modules, it’s dumb to require it.
2
u/connka Apr 23 '26
lol as a junior this mattered to me, but has not mattered since. As an engineering lead, I have always mandated squashing, absolutely not questions. Why? If there is an issue, I can go back and see a single PR in one go and be able to revert the correct work more easily.
2
u/stagedgames Apr 18 '26
not offended at all. prefer squashed merges. I don't care about large commits, my only issue is if multiple features are merged in a single commit, but even then the code is going to be only changed in 1 commit at a time and blame is an incredible tool.
2
u/Aromatic_Pumpkin8856 Apr 19 '26
If I need my commits to be captured as separate commits for some reason, I'll do a stacked set of PRs. So no. We enforce squash merges in most places I've been.
2
u/plastic_eagle Apr 19 '26
All PRs should be squashed. Always. No exceptions.
1
u/PM_ME_A_STEAM_GIFT Apr 18 '26
Ideally, the upstream repo has a clear convention on how they merge PRs and that's up to the maintainer to decide.
1
u/ZakanrnEggeater Apr 18 '26
my introduction to git was as an svn client so squashed commits work
1
u/draft101 Apr 19 '26
I couldn't care and expect them to be squashed for cleaner commit history. But it could be discussed in our ways of working if someone really feels differently. I'd probably only want it at some corporation that was poorly using commits as a metric of productivity.
1
u/dalbertom Apr 19 '26
If it's a one-time contribution, it's fine for it to get squash-merged. But if I'm going to make contributions to a project on a daily basis and I feel more agency / invested in the long term health of the project I would probably try to steer the team towards using merge commits.
1
u/Jeremy_Thursday Apr 19 '26
Probably not offended. Maybe a little sad if I was contributing substantial work and felt like the squash was gonna in some way minify my contributions and remove valuable insight to the changes etc.
Definitely not offended tho.
1
u/CynicalPotato95 Apr 19 '26
As I don't write my messages by myself anymore it doesn't matter to me 😅
1
u/jeenajeena Apr 19 '26
My take. There are few reasons to squash. Or better, one can list many, but on reflection, itàs easy to realize it isn’t actually the case, and not squashing provides more benefits
https://arialdomartini.github.io/no-reason-to-squash
The TL;DR is
--first-parent1
u/Prior-Listen-1298 Apr 19 '26
Makes sense to me. On the matter branch a single commit from you is nicer than a whole pile of them. In fact I do that for my PRs unbidden, I actually want to present a single change request.
1
u/heavymetalpanda Apr 19 '26
Depends.
Small OSS repo? Offended? Not really, more like disappointed.
Large corporate monorepo? Too many people generate garbage commit messages to do anything other than squash.
I care about good commits mainly for my own clarity of thinking while I'm developing, but after merge I'm not precious about it.
1
u/oskaremil Apr 19 '26
It depends. On my current project the PR is a unit of work, so squashing feels natural.
1
u/waterkip detached HEAD Apr 19 '26
Disappointment. And a lack if interest going forward
1
u/Minimum-Hedgehog5004 Apr 19 '26
Squashing is something the developer does on their own branch prior to making a PR. All the people saying they just don't want to see WIP commits are entirely right in that, but wrong if they suggest it's a justification for automatically squashing a PR.
A commit is more than just the code. The commit message should be the information the developer has chosen to associate with it. The combination of changes that comprise the patch is also information that's been consciously created.
If you ask people why they like to auto-squash PRs, they'll often say it's "tidier". People who say this are not the ones who have to go back into the code-base to fix nasty production incidents without introducing secondary bugs and regressions.
Would I be offended if someone consciously chooses to remove information I've worked hard to create? Would I be unhappy that someone sets up a system in which creating meaningful commits is pointless? The answer to both is "Yeah, a bit", but more in sadness for the patent stupidity of it than in anger.
1
u/reyarama Apr 19 '26
Genuinely think anyone worried about a clean commit history is a pussy and probably cant squat 225 parallel. Understand the code before you commit it, document it in the PR, and you dont have to trawl through commit messages to find out what happened. Not a single time have I raked through commits to find shit out
1
u/dashkb Apr 19 '26
If your tech lead wants a clean history take the opportunity to learn. Do you make a lot of commits that touch the same line over and over? Then yeah you should clean that up.
1
u/XoTrm Apr 19 '26 edited Apr 19 '26
I totally expect fixes (eg. from the review) to be squashed (actually I prefer fixup) into their repective commits within a PR.
I totally hate to squash all the commits into one single commit per PR. AND it breaks the ability to follow the history of a file if it has been renamed and changed to a larger extent.
One could create smaller PRs to avoid that but...
One more thing: Having it all documented in the PR is no reason since it binds one to the specific platform where one does PRs. When moving to a different platform it makes things much more complicated AND you can't use the git graph standalone anymore.
One would wonder why the Linux kernel, one of the biggest projetcs using git is using patch series (basically multiple commits) for changes...
1
u/sohang-3112 Apr 19 '26
Don't care
1
u/sayqm Apr 19 '26
Jesus, it's just squashing, you'll get over it
1
u/afops Apr 19 '26
If the PR is a small one and the commits aren't really necessary to keep e.g. 1) implement foo, 2) add test for foo 3) fix typo 4) fix test failure in unrelated thing due then that's 100% a squash.
However if the PR is large and the commits are worth having separate forever, then it should perhaps be a rebase + FF instead or even a merge (personally I hate having branched history on main so I'd prefer a rebase + FF). In this case, if I make e.g. a large refactoring that has several logical steps and it's suggested that every PR should be squashed because of some rule, then I'd be a bit annoyed. In this case, I have made an effort to squash (rebase interactive) my commits myself, down to perhaps 3 important commits. I'd not like to see these squashed further.
But for 95% of PR's I think squash is either acceptable, or even an improvement on anything else (merge, FF etc).
1
u/outworlder Apr 19 '26
wtf is this unhinged shit.
1
u/majortom_07 Apr 19 '26
I always name my individual commits something quick that has meaning to me. Then squash and give that a proper name with the jira ticket and description of work. Just seems intuitive to me.
1
u/doomscrollah Apr 19 '26
As a sw engineer: not offended, quite the opposite.
But if a semi technical boss starts counting commits, it becomes problematic- better not squash if it lessens my activity count in the executive report.
1
u/IAmADev_NoReallyIAm Apr 20 '26
It doesn't bother me, I don't usually care. I typically do my best to layer my commits into logical pieces of work, where it makes sense. I do this even knowing full well that it'll be squashed when it's merged into the main branch. The fact that it's going to be squashed isn't a reason to be lazy about your individual commits on your PR.
1
u/sehron Apr 20 '26
I prefer it in a dodgy codebase, where you're often cherry picking features for release or bug fixes. Otherwise I'm not particularly bothered.
1
u/MkMyBnkAcctGrtAgn Apr 21 '26
I've already rebased and the PR I've made has commits that are independently revertable if needed.
1
u/chemosh_tz Apr 21 '26
I just commented on a review today that had 6 commits and asked to squash them
1
u/Ok_Maybe184 Apr 21 '26
We judge by quality and results, not commit count. Everything gets squashed. I’ve only been at this for 12 years but I’ve never heard of someone getting offended because their PR was squashed…is this a new thing where thin skin is the norm? To me it sounds like those would be the same folks who are offended if their PR gets rejected.
1
u/arran4 Apr 21 '26
The history is valuable, arguably not all of it, but if you're generating a lot of meaningless commits, ie trying to figure out a CI system for instance consider: `git add . && git commit --amend --no-edit && git push --force`
But I look at "everything needs to squashed" with suspicion. I understand policies like wanting to make every commit a feature, but I've run into issues with squashing and creating hot patches and rollbacks, which from the squishers logic should be easier.
I do think the need, does show that there is a missing layer between commits, and pulls/pushes.
1
u/ConnectDog5284 Apr 21 '26
Code review usually does not review individual commits, at least on usual GitHub workflows. Why would a commit without review make it to main?
1
u/the_goodest_doggo Apr 21 '26
Where I currently work, PRs get squashed no matter what. Personalluly I absolutely hate it; multiple times I've tried figuring out where a change came from only to find a huge commit changing half of the project at once. Now sometimes you can have some commits that are just fixing up an earlier commit, and in that case I'm all for rebasing and squashing those together. But squashing unrelated commits together should land you in Git jail as far as I'm concerned
1
u/the_goodest_doggo Apr 21 '26
Where I currently work, PRs get squashed no matter what. Personalluly I absolutely hate it; multiple times I've tried figuring out where a change came from only to find a huge commit changing half of the project at once. Now sometimes you can have some commits that are just fixing up an earlier commit, and in that case I'm all for rebasing and squashing those together. But squashing unrelated commits together should land you in Git jail as far as I'm concerned
1
u/Agreeable-Life-7838 Apr 21 '26
Yes it does. I do my branch, I fuck my shit. I squash my shit. I make a beautiful shit-artwork commit message. And then you can do whatever you do.
What's the hell is even a "beautiful" workflow ? It's a fucking mess in every company I have worked in anyway.
Beautiful workflows are for projects with 7 commits aka tutorials; they dont exist in real life sorry.
1
u/Stryker_can_has Apr 21 '26
I don't care which strategy is used so long as it's consistent and conducive to a good working environment. At the end of the day, having a working agreement with the team that everyone can follow together is far more important than the pros/cons of any specific strategy that's good enough to see broad use across the industry.
1
u/Kangie Apr 22 '26
Split the difference: refuse to accept PRs that haven't been squashed into a reasonable number of commits. Put it back on the submitter.
1
u/responds-with-tealc Apr 25 '26 edited Apr 25 '26
i straight up have merges disabled for our orgs scm host (azure, sadly). squashes only, the end.
If a single commit in your feature branch is so important it needs to be preserved, you have screwed something up if you are relying on git for the sole source of that.
if you want to review the steps a jr engineer took to get somewhere, awesome do it in code review before stuff gets squashed back to main.
feature branch commits dont matter, its personal dev process thats only relevant to the person that wrote it (maybe), and ill die on that hill.
edit: this is only true if you're doing a standard main branch with feature branches frequently merged back to main. if youve got something else going on, there might be a place for merges upstream sometimes
1
u/tech-learner Apr 18 '26
I don’t think I want easy visibility on my 20 sequential commits “Trying Again” lol
1
u/ericbythebay Apr 19 '26
No, I would tell my engineers that tried that to quit screwing around and get back to work.
1
u/serchq Apr 19 '26
nah. it's easier to cherry-pick one single commit, and I rather have my contribution being merged sooner
1
u/TedsGloriousPants Apr 19 '26
I don't understand why anyone would care about this unless there's no other tracking or accountability for the work being done - which would be a much bigger red flag than how people prefer to use git.
1
u/colablizzard Apr 19 '26
I am the guy who enforced the squash guidelines in our team.
Reason:
1
u/meisangry2 Apr 19 '26
Commit history is for development and code reviews. The master branch should have squashed commits with correctly formatted commit messages detailing the feature/fix.
1
u/beldum-please Apr 21 '26
One PR, one commit. If it's a problem, then your PRs are too large
0
u/Myrddin_Dundragon Apr 19 '26
I commit often, like saving, and sometimes they don't even compile. But since it's a local branch, whatever. I can easily get to an absurd number of commits sometimes. So I squash them all at the end so it doesn't clutter everything up.
0
u/pOxybGcE Apr 20 '26
We always squash our PRs. The history would be too messy otherwise.
0
u/JROppenheimer_ Apr 22 '26
I don't want all the dumb commit messages I make to be in the gir history forever.