News for hackers. Stuff that matters.
Re:Julia Evans: Git rebase, what can go wrong by dkarl on Monday November 06, 2023 @01:08PM (#38166242)
I think squash merges are a last resort heavy-handed tool for dealing with developers who refuse to clean up their commit history before merging. Most developers can do better by hand.

Git history should tell a simple, understandable story of each change. For example: 1) refactor existing code, 2) add feature. Or 1) add missing tests, 2) refactor existing code, 3) add feature.

But since you're working on the fly with imperfect knowledge, it doesn't happen in such neat steps. Refactorings and behavior changes end up interleaved in your raw git history, so you need to do a little bit of cleanup by hand in order to present a simple story in the commit log.

Of course if you have developers that don't do that and instead merge dozens of commits that just say wip, wip, wip, lol, fml, wip, wip, lol, yolo and you can't fire them or get them to change, then squash merges ftw.

Re:Julia Evans: Git rebase, what can go wrong by bogeholm on Monday November 06, 2023 @01:16PM (#38166399)
I ser it the other way around - why spend time on a ‘nice’ commit history in a (smallish) feature branch when you can squash merge later.

I prefer one commit to main per feature, a long with a good description on the GitHub PR.

Sometimes I’ll branch out from a feature branch for the occasional and infamous ‘get CI working’ round of 10 one-line commits though, to not make it too muddy.

Re:Julia Evans: Git rebase, what can go wrong by ufo on Monday November 06, 2023 @02:03PM (#38167166)
Precisely, you want to keep it about one commit per feature. I think the parent comment was worried about monster merges that squash many features together.
Re:Julia Evans: Git rebase, what can go wrong by marcandre on Monday November 06, 2023 @02:31PM (#38167606)
The classic example where this fails is when needing to revert something. An atomic commit for the migrations + some atomic commits for the implementation mean you can easily revert the implementation, and leave the migration intact (as should be) and add a reverse migration.
Re:Julia Evans: Git rebase, what can go wrong by gwright on Monday November 06, 2023 @02:34PM (#38167657)
> why spend time on a ‘nice’ commit history in a (smallish) feature branch when you can squash merge later.

Several reasons: * facilitates much better code review discussions * enables use of git bisect to locate bugs * allows for informative commit messages associated with the changes * communicates clearly to future self about why changes were made

Re:Julia Evans: Git rebase, what can go wrong by u801e on Monday November 06, 2023 @02:44PM (#38167828)
Another good reason is that having a small commit that changes just one thing is a lot easier to revert without encountering conflicts, even after other features have been committed to the main/master branch.
Re:Julia Evans: Git rebase, what can go wrong by toast0 on Monday November 06, 2023 @02:44PM (#38167838)
> * enables use of git bisect to locate bugs

This is really only viable if each intermediate commit on a development branch is intended to be bug free. If that's the standard you and your team work with, that's fine, but it's not usually my standard; in a development branch, I may commit things that don't even compile, let alone work, if it's a good point to commit.

Re:Julia Evans: Git rebase, what can go wrong by bonzini on Monday November 06, 2023 @02:49PM (#38167895)
The point of the parent comment is exactly that you should clean up the history before merging to a public branch, so that you can use bisect, even if so far you had wip wip doh wip as the commit messages. The way to get there is to have a mix of proper and wip commits.
Re:Julia Evans: Git rebase, what can go wrong by WorldMaker on Monday November 06, 2023 @03:13PM (#38168270)
If merge points are your "known good" points anyway you can just use the powers of the git dag and `git bisect --first-parent` in your main branch to just bisect the merge points. There's no need for rebase/squash and you still get useful git bisect results.
Re:Julia Evans: Git rebase, what can go wrong by bonzini on Monday November 06, 2023 @03:47PM (#38168757)
All commits are good points and potentially useful points. Was the bug in the refactoring? In the feature itself? In the resolution of merge conflicts? You can only answer if you don't squash, and it becomes easier to fix the bug if you know the answer.
Re:Julia Evans: Git rebase, what can go wrong by WorldMaker on Monday November 06, 2023 @04:45PM (#38169454)
Sure, but also no one particularly wants to CI every commit inside a PR, so there is a usefulness in `git bisect --first-parent` as the "first pass" of known CI points (merge commits presumably from PRs) to find the "PR that introduced the problem" and then drill down into every smaller commit to see if you can get additional bisect information (from commits that may or may not have passed CI in the first place in development work-in-progress).
Re:Julia Evans: Git rebase, what can go wrong by bonzini on Tuesday November 07, 2023 @02:06AM (#38174021)
I don't do full CI for every commit but I do run the relevant unit tests (or all of them depending on the change and the project) and ensure that they pass.
Re:Julia Evans: Git rebase, what can go wrong by dkubb on Tuesday November 07, 2023 @02:15AM (#38174066)
I think the point the GP message is making is that, prior to review/merge you extract atomic commits from your WIP that tell a clear, concise story of how the change was made. The reviewer has less built up context so by chunking it like this they can step through each commit one at a time.

IMHO the expectation is that each commit would 100% pass CI, so if you decided to extract some commits and merge that early you can. This is especially useful when a 6 commit PR is reviewed, and the first 3 commits are fine but there is more feedback on the last three. The reviewer can split the first 3 good ones out, get them merged and whittle down the PR to the remaining three. The subsequent follow up will be less.

IME team velocity goes up with this too, and it encourages small and easy to review commits like a Remove to be extracted and merged early.

Since PRs are always as large or larger than commits, I would much rather have a specific commit flagged than have to wade through the whole PR diff. If the PR is not familiar to me, I want to increase my effectiveness narrowing down the cause, so I can fix it faster.

Re:Julia Evans: Git rebase, what can go wrong by watwut on Monday November 06, 2023 @03:18PM (#38168357)
Frankly, people lately spend more time managing commit history then using it. Like, commit history is useful once in a year little bit, maybe, but we spend absurd amount of time trying to make it look nice.
Re:Julia Evans: Git rebase, what can go wrong by gwright on Monday November 06, 2023 @03:29PM (#38168524)
Not my experience, nor my team's experience over almost 10 years of using this approach.
Re:Julia Evans: Git rebase, what can go wrong by Chris_Newton on Monday November 06, 2023 @04:41PM (#38169426)
I’m firmly in your camp on this one, but I’ve noticed that advocating a tidy history gets a lot of push-back online. I think there is an element of self-fulfilling prophecy here. If a team habitually leaves a messy history behind, that history is rarely going to be useful, so naturally the team has low expectations and sees little value in doing anything to curate it. And if a team isn’t used to making an effort to curate its history, they may assume that doing so is expensive because `git rebase -i` is scary and not something they use on auto-pilot for a few seconds at a time.

In other news, our developers also create several small PRs every day but each is for an incomplete change that doesn’t stand alone so we’re never quite sure which features are finished in any given build, everyone keeps complaining about being interrupted to do code reviews all the time when the code reviews have no value anyway because they always just say LGTM :+1:, and we have targets that no more than 15% of commits should break production when CI/CD deploys them and that we recover fully within an hour each time that happens. If only there were something we could do to improve all this…

Re:Julia Evans: Git rebase, what can go wrong by watwut on Monday November 06, 2023 @05:06PM (#38169736)
I worked in a team where tech lead insisted on nice history. It was a lot of effort all the time and very little to no benefit.

He was lead and could influence salaries, his opinion mattered. So, in real life, people rarely pushed back. That is not the same as us sharing the same opinions tho. I became more verbal about history not being useful online.

Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Monday November 06, 2023 @05:21PM (#38169929)
If a strategy requires humans to be virtuous AND vigilant it is doomed to failure.

I rarely use history and prefer merge/squash, with automated CI tools, and tests. "Why" is kept in doc strings, comments, specs, and story tickets. Everything viewable in gitlab with automatic links. All this gets out of the critical path, every day.

I submit that, if your code is so complex that diagnosing a bug is a major research project rather than moving forward with a few extra/modified lines of obvious fix, then that is the problem to focus on.

Re:Julia Evans: Git rebase, what can go wrong by Chris_Newton on Monday November 06, 2023 @06:08PM (#38170507)
If a strategy requires humans to be virtuous AND vigilant it is doomed to failure.

Sorry, but I don’t buy that. By the same principle, there’s also no point in writing unit tests or defining static types or having code reviews, all of which require thought and extra work, yet can yield considerable dividends when done even moderately well.

I rarely use history and prefer merge/squash, with automated CI tools, and tests. "Why" is kept in doc strings, comments, specs, and story tickets.

The argument for a tidy history isn’t just about a different place to explain a change. It’s about presenting work in clearly defined, meaningful steps to other readers like code reviewers, or perhaps someone who found these commits later through `git blame` on a problematic line of code or `git bisect` after a regression. It’s about each commit representing a complete, self-contained change that could later be reverted, or cherry-picked or merged to another branch.

I submit that, if your code is so complex that diagnosing a bug is a major research project rather than moving forward with a few extra/modified lines of obvious fix, then that is the problem to focus on.

Some problems have a lot of essential complexity. The code to solve them necessarily has at least the same degree of complexity. Sooner or later, there will probably be a change to that code with an unintended consequence for something else. Keeping the code and its history tidy and systematic is, IMHO, how you avoid those investigations becoming major research projects.

Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Monday November 06, 2023 @10:18PM (#38172794)
One of these things is not like the other. (Journey vs. final destination.)

As an industry we get paid primarily for 1) working software and 2) communicating with stakeholders.

Tidy yet inaccessible (to non-dev) construction stories are not on that path. I would argue unit tests et al are, to ensure #1.

No stakeholders? Put why into a readme, where it can be seen at a glance.

Complexity must be broken down into bite-sized chunks for a solution to be feasible in the first place, reliable in the second. i.e. skull-size limits. If there’s any code I don’t understand I rewrite it until I can. With tests of course.

Re:Julia Evans: Git rebase, what can go wrong by Chris_Newton on Tuesday November 07, 2023 @05:10AM (#38175138)
Sorry again, but I’m still not seeing the distinction I think you’re trying to make here.

I see version history as an asset, just like the code itself, tests, developer documentation, the bug tracker database… None of these things are directly visible to end users under normal circumstances, but they are useful sources of information and organisation and collaboration that help developers to create the software that users do see.

To me, a repo with a messy version history is like code full of superficial comments, a test suite with high coverage metrics that still doesn’t exercise the most important functionality, a dev team where the only documentation is some auto-generated static site that reproduces what any decent IDE would show in real time anyway, or a tracker where all the tickets are vague one-liners. You can produce useful software despite those things, but why would you?

Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Tuesday November 07, 2023 @06:36PM (#38184659)
It's not a black and white distinction, I agree.

Also, I said/meant stakeholders not end-users. Ours definitely do write bugs, look at docs and generate db reports etc.

The main distinction is that things on that list have a high cost-to-benefit ratio to goals 1 & 2, where history maintenance does not. The cost is high and utilization isn't. Additionally it can't be used to communicate with anyone but developers.

Re:Julia Evans: Git rebase, what can go wrong by watwut on Tuesday November 07, 2023 @06:22AM (#38175557)
> there’s also no point in writing unit tests or defining static types or having code reviews

Not true. I do not do those to have nice clean process. I do unit tests, because without them the code is unstable and it is hard to fix bugs without causing unrelated ones. If the code is super simple and unlikely to break, I don't do test. I like to use static types, because I am much faster when writing them. The code is more readable and I have less bugs. Now, I have seen both useless and useful code reviews.

But, in all of those cases, things are done because they beneficial impact in final code and speed of delivery. Beautiful git history does not have such tangible measurable benefit. Git blame and bissect work without it, you just need one more step once in a while.

Re:Julia Evans: Git rebase, what can go wrong by Chris_Newton on Tuesday November 07, 2023 @07:48AM (#38176154)
But, in all of those cases, things are done because they beneficial impact in final code and speed of delivery. Beautiful git history does not have such tangible measurable benefit.

I respectfully disagree. In my experience, a tidy history directly benefits both efficiency and outcomes of code reviews, speeds up investigations of both bug reports and sometimes general background before starting new development, makes development much easier in situations where changes may need to be isolated and deployed to specific environments (not all software is a web app using CI/CD…), makes it much easier to back out a problematic change without causing unnecessary collateral damage, and helps to verify which development has actually been completed and deployed to which stages/environments, which can be useful for general awareness around the team but is particularly important if you’re operating in any kind of regulated field. All of that in exchange for usually spending less time in `git rebase -i` than it’s taken me to write this comment seems like a bargain to me, but YMMV.

Re:Julia Evans: Git rebase, what can go wrong by seba_dos1 on Wednesday November 08, 2023 @08:38AM (#38190106)
Fully agreed. Seems to me that most people who don't care about curating their commits (and either leave a mess or squash everything at merge regardless of context) simply don't work on projects that are either complex, distributed or long-living enough, so they can easily afford such carelessness.
Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Wednesday November 08, 2023 @05:18PM (#38197947)
Nope, ~15 year project here. No one is reading obsolete commit messages when there are hundreds of files to get familiar with today.

Not to mention quality is significantly higher now so you wouldn't want to refer to a granular history of crap anyway. Any time spent on that would have been completely wasted as I wipe out a thousand line file for a new one with a hundred lines because requests hadn't been invented yet and the original implementer didn't understand network protocols or how to use argparse and implemented it from scratch poorly.

Re:Julia Evans: Git rebase, what can go wrong by seba_dos1 on Thursday November 09, 2023 @12:08AM (#38201387)
Yeah, as I suspected.

If you can afford your first instinct to be reimplementing things from scratch, your understanding of the value provided by proper version control will be limited. Some of us work with constantly changing code developed by thousands of people from all around the world in projects that 15 years ago were migrating to git and that have tons of downstreams, and are thankful for maintainers and processes that keep the commit graph useful.

Though that said, once you're comfortable enough with git you'll be thanking yourself for commit hygiene even when coming back to your few years old single-person codebases.

In my experience, developer's work consists mostly of gaining understanding of codebases. It's like being a detective. Writing new code happens too, but not as often and it's not as impactful (and usually can and should be handled by less experienced devs). The most impactful things are single line changes that took a week to write, or a few dozen lines that took months. Rewriting existing code from scratch is something that happens only as a last resort and after very careful consideration. Maintaining some basic version control hygiene makes a whole world of difference in such work. Sure, you can live without it, but you can also live without docs, comments or tests (and sometimes have to - which makes you appreciate them when they're there).

Re:Julia Evans: Git rebase, what can go wrong by seba_dos1 on Monday November 06, 2023 @08:14PM (#38171792)
> I think there is an element of self-fulfilling prophecy here.

This too, but there's another thing at play as well: many developers don't know git at all. They just memorized enough commands to let them do their work. They don't understand what they're doing, so they can't reap the benefits of the tool they use. You won't get much use of RAW photos if all you can do in a graphics editor is clicking "auto enhance" button.

Re:Julia Evans: Git rebase, what can go wrong by nilptr on Monday November 06, 2023 @03:57PM (#38168890)
I use commit history a little bit more than that, but mostly agree. I had another dev recently give me crap about the mess of "WIP" commits on a feature branch because they review by clicking through the commits and my commits don't tell much of a useful story other than I apparently did some shit and eventually it all worked.

That said, I've also come to the conclusion there's basically two classes of Git users: people who really understand Git and use it fully, and those of us who basically use it as a place to shove source code before quitting for the night.

Re:Julia Evans: Git rebase, what can go wrong by Terr_ on Monday November 06, 2023 @04:43PM (#38169441)
> Frankly, people lately spend more time managing commit history then using it.

At one company with a Giant Custom Enterprise App, I ended up occasionally acting as a historian for pieces of the company with bad communication/institutional-memory, ex: "Oh, the +5% Foo charge was because of a request 3 years ago by vice-president X, here's the ticket number, before that it used to be +3%."

In those circumstances--where the implementation is the source of truth for business process--a well-maintained stream of commit-messages become quite useful.

Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Monday November 06, 2023 @05:28PM (#38170010)
Comment with a ticket-id would be more efficient.
Re:Julia Evans: Git rebase, what can go wrong by Izkata on Monday November 06, 2023 @07:04PM (#38171155)
On a long-lived codebase you're going to end up with nearly as many such comments as there are lines of code. Now that's a cluttered mess.
Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Monday November 06, 2023 @09:22PM (#38172387)
When/how to comment is an art in itself, in no conflict to what I wrote.
Re:Julia Evans: Git rebase, what can go wrong by Terr_ on Tuesday November 07, 2023 @01:04AM (#38173741)
While it's often said that comments should capture the "why" of code, I don't usually think that ought to extend to "cuz ticket#" except when that ticket number is an significant bug/limitation that explains a nasty hack.

Noting each feature ticket that ever affected a line--or even just at the function level--is sort of like maintaining a few thousand incomplete micro-changelogs. Doing it "acceptably well" takes much more effort than grooming the commit history so that someone can click "show change history for selected lines" in their IDE.

Plus consider all the unnecessary noise it makes for people reading the code, or reviewing a PR.

Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Tuesday November 07, 2023 @06:28PM (#38184585)
No, it's not difficult (cut/paste), nor a burden for reading in comments or docstrings. Could be measured in seconds instead of hours massaging history.

Also, you seem to be under the misconception history doesn't exist because it wasn't massaged, which is false.

Re:Julia Evans: Git rebase, what can go wrong by Izkata on Tuesday November 07, 2023 @08:25PM (#38185570)
And the commit message is an amazing place to put that.
Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Wednesday November 08, 2023 @05:15PM (#38197914)
Not if you want them read by non-developers.
Re:Julia Evans: Git rebase, what can go wrong by Izkata on Thursday November 09, 2023 @06:42PM (#38212981)
Why would you have non-developers reading code?
Re:Julia Evans: Git rebase, what can go wrong by m000 on Monday November 06, 2023 @04:50PM (#38169523)
Curating the commit history takes like 10' per PR and can easily repay in hours of work when some bug hits. Or when you want to tell the junior that wants to implement X for A, why don't you take a look on this one commit where we implement X for B?
Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Monday November 06, 2023 @05:32PM (#38170049)
Is there something wrong with the latest version of the method? Instead of one from ~18 months ago which may not work any longer?
Re:Julia Evans: Git rebase, what can go wrong by m000 on Monday November 06, 2023 @06:05PM (#38170475)
I'm not sure I get you. What do you mean the "latest version of the method"? And why shouldn't code from 18 months ago not work? Some minimal regression testing should be in place for production code, and it is probably also used regularly.

So, yes seeing e.g. how "CSV export for class A" is implemented is a great guide for implementing "CSV export for class B".

Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Monday November 06, 2023 @09:43PM (#38172539)
Most recent. Interfaces change over time.

Everything you need is in the most recent copy. Showing an old one invites difficulty for no benefit.

Re:Julia Evans: Git rebase, what can go wrong by deredede on Tuesday November 07, 2023 @01:40AM (#38173908)
A commit is not a method, it is a change set potentially affecting many files. Pointing people to the commit used to implement feature A lets them understand the whole story of which components need to change (and how) to implement similar feature B in a way that pointing them to a single method or file doesn't necessarily can.
Re:Julia Evans: Git rebase, what can go wrong by watwut on Tuesday November 07, 2023 @05:07PM (#38183655)
The idea is for junior to learn from massive commit that affected many files?
Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Tuesday November 07, 2023 @06:13PM (#38184422)
This reply is overstating a bit, but it does sound like a lot of work simply to avoid saying, "here look at these methods in this file" and the unstated, and trace the imports yourself.

Not to mention just finding the right commit months later sounds like more work than that already.

Personally, even if I were to make the history absolutely perfect, I never get the code right (interfaces etc), the first time. It might be hours or days before I'm 98% happy with the final implementation. Sometimes big refactor opportunities come to me days or months later, e.g. where I move code needed multiple times into a more central mixin location.

Re:Julia Evans: Git rebase, what can go wrong by erik_seaberg on Monday November 06, 2023 @05:49PM (#38170270)
If I can invest business hours and get back minutes during an outage at 3 AM, I should do that.
Re:Julia Evans: Git rebase, what can go wrong by krferriter on Wednesday November 08, 2023 @11:15AM (#38192524)
Yeah I just don't care really. I have noisy dev branches, force pushing rebases from an upstream branch, and usually just squash merge and throw the history away when merging back to master. I've never come across a situation where I needed a preserved, fine-grained commit history for every dev branch after they've already been put in working order and merged to master. I guess I just don't use commit histories very much after the fact, like months later trying to find what original commit changeset a line of code was changed in. It's never mattered.
Re:Julia Evans: Git rebase, what can go wrong by funcDropShadow on Friday November 10, 2023 @05:19AM (#38217149)
I use the commit history every time a I open file I haven't worked on for a while. Just seeing the output of git annotate in the border of Intellij gives me a sense how old code is, what changed together with what and whom to ask in case of questions.
Re:Julia Evans: Git rebase, what can go wrong by Terr_ on Monday November 06, 2023 @04:40PM (#38169409)
[delayed]
Re:Julia Evans: Git rebase, what can go wrong by seba_dos1 on Monday November 06, 2023 @07:31PM (#38171408)
Of course I commit a lot of garbage commits that don't work, it's super useful to do so. Those never get pushed out into branches that I share to others though - why would I waste their time having them look at those?

What I push out are atomic commits that make sense logically, not an external undo log of my text editor; squashing those on merge provides no benefit and only loses useful information. Squashing should happen before push, not on merge, and there's no reason to have buggy "intermediate" commits at all.

Re:Julia Evans: Git rebase, what can go wrong by u801e on Monday November 06, 2023 @08:58PM (#38172198)
> > * enables use of git bisect to locate bugs

> This is really only viable if each intermediate commit on a development branch is intended to be bug free.

git rebase has an --exec option that allows you to run a command or set of commands for each commit in the branch. You could rebase your development branch before pushing it up for review and ensure each commit passes coffee linting and tests.

Re:Julia Evans: Git rebase, what can go wrong by bogeholm on Monday November 06, 2023 @05:18PM (#38169881)
> facilitates much better code review discussions

Hmm, I usually mark PR’s as draft until ready for review, and then I expect the discussion to be about the current state, not a previous intermediate state. Easiest with small PR’s.

> enables use of git bisect to locate bugs

Interesting. I know _of_ git bisect, but haven’t used it as part of my workflow. Have you found it useful to bisect commits on a feature branch (which, presumably, represents unfinished work)?

> allows for informative commit messages associated with the changes

I find using the PR title and accompanying info in GitHub or similar to be quite informative - that should convey the purpose of the change.

> communicates clearly to future self about why changes were made

See above. Perhaps we work differently, but I find it clearer to read a git history where each commit represents a single, complete feature/fix/refactor instead of intermediate steps.

Re:Julia Evans: Git rebase, what can go wrong by sangnoir on Monday November 06, 2023 @05:49PM (#38170274)
There are a multitude of Git workflows, and opinions on what the basic unit of change is: for some, a feature is atomic, so squash-merging feature branches is perfectly natural.

> facilitates much better code review discussions

This can be done while adding code to the feature branch

> allows for informative commit messages associated with the changes

I'm assuming you consider individual commits to be the basic unit of change? This isn't always the case. Some products are not amenable to adding features fractionally

> communicates clearly to future self about why changes were made

You can do that with a squash-merge too!

I've noticed people who work on an evergreen deployment can afford to work on a very granular, commit-level. However, if you have to support multiple production branches concurrently and often have to cherry-pick features and fixes across them, features will naturally become the basic unit of change you will find yourself gravitating towards, and will liberally use squash-merging just to keep your sanity.

Re:Julia Evans: Git rebase, what can go wrong by folmar on Monday November 06, 2023 @03:43PM (#38168696)
If things are heading towards a single commit an amend commit works fine for me. If I need a previous state I just get it from reflog.
Re:Julia Evans: Git rebase, what can go wrong by m000 on Monday November 06, 2023 @04:44PM (#38169450)
> I ser it the other way around - why spend time on a ‘nice’ commit history in a (smallish) feature branch when you can squash merge later.

Squash-merge is a scourge. I've seen squash merged commits 30 lines long ("try 15", empty line, "try 14", empty line...). I'm not even sure if you can do anything about such commits because squash-merge is a github/gitlab thing. So, I'm not sure if there are hooks to block it via a commit message linter.

And I've seen people going through some intense mental gymnastics to justify avoiding squashing locally, writing a proper commit message and then merging.

Re:Julia Evans: Git rebase, what can go wrong by throw555chip on Monday November 06, 2023 @04:47PM (#38169489)
> why spend time on a ‘nice’ commit history in a (smallish) feature branch when you can squash merge later.

Agreed, it has been standard at most shops I've worked in the past 8-10 years.

Re:Julia Evans: Git rebase, what can go wrong by joshribakoff on Monday November 06, 2023 @01:28PM (#38166618)
You can simply ask “git log” to show you one coarse entry per Pr rather than “destroying” the more granular history
Re:Julia Evans: Git rebase, what can go wrong by erik_seaberg on Monday November 06, 2023 @02:45PM (#38167855)
This. It bugs me that people permanently throw away details of changes rather than show just the log of merge commits.
Re:Julia Evans: Git rebase, what can go wrong by hhjinks on Monday November 06, 2023 @03:30PM (#38168537)
Why would I want to keep the details? Umpteen "tmp", "fix" and "fixed typo" provide negative value. When I check the blame of a line, I need to see the context of the change, meaning a description of all the work that was done as part of that change, and perhaps a ticket number. Anything else is noise that actively detracts from the value of the log.

It's like 4K porn. It's less appealing when you see everything.

Re:Julia Evans: Git rebase, what can go wrong by mablopoule on Monday November 06, 2023 @03:42PM (#38168685)
No yeah, absolutely do squash those commits, they are actually polluting the git history.

The issue for me is when commit who are about adding a new value in the env file become mixed with template and responsive handling, mixed potentially with a bug fix.

Re:Julia Evans: Git rebase, what can go wrong by jimbob45 on Monday November 06, 2023 @01:21PM (#38166479)
I think squash merges are a last resort heavy-handed tool for dealing with developers who refuse to clean up their commit history before merging. Most developers can do better by hand.

This is too much thought put into a VCS. I don’t want to have to think about my VCS at all beyond the commit message. For all of Git’s popularity, I’ve never seen benefits that justify the absurd amount of work and knowledge it takes to perform simple actions. It’s the VCS equivalent of Scheme or emacs.

Re:Julia Evans: Git rebase, what can go wrong by dkarl on Monday November 06, 2023 @01:36PM (#38166747)
It really pays the effort back, though, when you can figure out why something was done, beyond knowing the feature it was related to, which is all you get with a squash merge.
Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Monday November 06, 2023 @05:53PM (#38170317)
Why not document it then? In a place where everyone can read it, instead of only developers.
Re:Julia Evans: Git rebase, what can go wrong by Izkata on Monday November 06, 2023 @07:10PM (#38171202)
...are you suggesting spending hours searching through documentation, hoping to possibly find something relevant, instead of just being able to run "git blame" to see why a specific line was changed?
Re:Julia Evans: Git rebase, what can go wrong by mixmastamyk on Monday November 06, 2023 @09:38PM (#38172504)
I use blame often so sounds like you misunderstood.
Re:Julia Evans: Git rebase, what can go wrong by scme0 on Tuesday November 07, 2023 @05:47AM (#38175362)
But if you're using pull requests, you can just look up the PR to get the reasoning and details of the squash commit. I would argue that if you need it to be separate commits after merging, you should create separate PRs most of the time.
Re:Julia Evans: Git rebase, what can go wrong by mablopoule on Monday November 06, 2023 @01:27PM (#38166586)
It's not about VCS, it's about code, both now and later, and context.

If you need to do a workaround, or a complicated feature sometime it's nice to explain it as a comment in the code, but sometime it's better to put it as a comment inside the commit message. But if it's all merged i the end, along with lots of template changes, README changes, refactor irrelevant to the current changes, then you're losing an important way of navigating a codebase.

Re:Julia Evans: Git rebase, what can go wrong by Dylan16807 on Monday November 06, 2023 @03:14PM (#38168295)
> I don’t want to have to think about my VCS at all beyond the commit message.

Fine as an opinion.

> For all of Git’s popularity, I’ve never seen benefits that justify the absurd amount of work and knowledge it takes to perform simple actions. It’s the VCS equivalent of Scheme or emacs.

This is just wrong. When people talk about this, it's not about git at all.

You write some code, and you make it into commits. Part of that is choosing if/how to organize it with multiple commits, and how much effort you want to put into that. This is fundamental to using a VCS, any VCS.

Or by analogy, if a lot of emacs users complain about your spelling, that's not because emacs is overly demanding.

Re:Julia Evans: Git rebase, what can go wrong by jdhzzz on Monday November 06, 2023 @03:40PM (#38168661)
That was me.

Got fired. Kinda. I was laid off.

Re:Julia Evans: Git rebase, what can go wrong by silenced_trope on Monday November 06, 2023 @04:08PM (#38169044)
I disagreed with you up to this point:

> Of course if you have developers that don't do that and instead merge dozens of commits that just say wip, wip, wip, lol, fml, wip, wip, lol, yolo and you can't fire them or get them to change, then squash merges ftw.

Yes, any large organization has plenty of devs who all have their own style and preferences, for better or worse.

Whoever demands they all bend to the one true way is a fascist (lol not really but you know).

Just set up your CI/CD in such a way that PRs with weird git logs get squashed into one pretty message, preferably the PR description since other devs have to review the PR it's often given more effort. Set it up so that if things weren't formatted the "right way" they get auto-formatted or a test fails and the dev says "ah, I have to run that one task and then update the PR".

I don't think a big organization is going to scale with developer "evangelists" demanding people write their commits a certain way either.

conventionalcommits.org was the worst. I worked at one "big co" that tried to get devs to do this. Even after we had been doing it for a while, nobody ever went back to look at the history in such a way that it was worth it. We ended up throwing in the towel rather than the company trying to get all other teams to do it.

Re:Julia Evans: Git rebase, what can go wrong by zaptheimpaler on Monday November 06, 2023 @04:47PM (#38169492)
I get why you would prefer it clean but its just too much overhead for me. I naturally make lots of changes together - especially on a complex feature, you need to build things in a "full-stack" way horizontally so you can test as you go. Then pulling things apart into "clean" atomic commits later just takes too much time and I don't really know how to do it efficiently.
Re:Julia Evans: Git rebase, what can go wrong by yxhuvud on Monday November 06, 2023 @05:30PM (#38170024)
The thing is that when you get good at it the overhead will go down drastically. And the practice will make it easier and faster to extract small pull requests out of your main work that can be reviewed separately.
Re:Julia Evans: Git rebase, what can go wrong by Rapzid on Monday November 06, 2023 @06:07PM (#38170494)
There is a reason so many open source projects require squashing.

Ain't nobody got time for that shit.

Re:Julia Evans: Git rebase, what can go wrong by leptons on Monday November 06, 2023 @06:14PM (#38170581)
It's like if someone said they wanted to invite you over for dinner. Then they started texting you. "at the grocery store". "bought a pound of beef". "bought some carrots". "Checking out now". "Arrived at home". "Turned oven on". "Turned oven to 450 degrees". "Turned oven up to 460 based on different recipe". "Starting to prep the beef now". and so on, and so on. I mean, just cook the damn dinner - I don't need to be needled about all the steps. I'll come over and bring the wine, and we'll eat a meal. I don't need to know every minor implementation detail in a commit log, to review and merge the branch. Arghhhh I have one dev on my team like this right now. I'll have to have a talk with them.
Re:Julia Evans: Git rebase, what can go wrong by smcleod on Tuesday November 07, 2023 @06:34AM (#38175643)
Eh, commit history is handy to have but if you spend all your time crafting the perfect commit messages and history you’ve likely lost sight of what matters. Great is the enemy of good and make the tools do the work for you. Commit as many WIPs or whatever then just hit squash and merge - it saves a lot of time and keeps momentum up.