Live data from Hacker News

Fortunately, I don't squash my commits

blog.ploeh.dk

31–40 of 333 posts

Re: Fortunately, I don't squash my commits

#31
post #28

Earlier quoted context omitted.

You do keep the history in the branch, it's just out of the way unless you really need it. Also, the method I described has nothing to do with commits. PRs and small commits aren't mutually exclusive.

You have to go dig the branch out of the central repo, though, which is annoying and takes time. That was the price I was thinking of. You're certainly right that PRs and large commits are orthogonal.

I've done this maybe once or twice a year.

Re: Fortunately, I don't squash my commits

#32

One obvious requirement for bisect to work is that your code builds on every commit - and so does everybody else participating in the git history. Straw poll - do you enforce this? If so, for literally every commit, or do you use partial squashing to maintain this property? While that's certainly a _desirable_ property, I've never really been concerned if, say, the penultimate commit on a PR failed CI. It feels like…

I've always been careful about this even though I've not had the habit reward me yet (3 years of exp). If I'm rebasing, I go through every commit and make sure it builds.

TIL about `git bisect` and it's really vindicating.

Re: Fortunately, I don't squash my commits

#33
post #5
post #2

Do people out there actually squash commits? Granted, I didn't change many work places in my career, but at no place where I worked people squashed commits. What's even the point of it? It's not like people routinely read the commit history, and when they do, they really would like a complete story, not 20 gargantuan commits that contain 3 years of development.

I always squash my commits and at my current place that is even enforced via phabricator

Phabricator has a quite different (I would say better, others would say worse) development flow philosophy to GitHub/PRs.

Phabricator’s preferred model, which is heavily influenced by Facebook, is to forgo feature branches entirely and just stack many small changes on top of each other, landing as and when you want (this doesn’t preclude you working on feature branches locally, of course, because Phabricator doesn’t care what your local checkout looks like).

Because of this, Phabricator considers each diff to be discrete, and if you have multiple changes making up a single feature they should in turn be broken down into separate diffs.

Personally, I think stacked diffs are the killer feature of Phabricator. Unfortunately I haven’t been able to find a similar flow with PRs (recently we migrated from Phabricator to GitHub for one of my projects), you end up fighting against the tool a lot.

Re: Fortunately, I don't squash my commits

#34

One obvious requirement for bisect to work is that your code builds on every commit - and so does everybody else participating in the git history. Straw poll - do you enforce this? If so, for literally every commit, or do you use partial squashing to maintain this property? While that's certainly a _desirable_ property, I've never really been concerned if, say, the penultimate commit on a PR failed CI. It feels like…

There is no such requirement, you can just skip commits which cannot be tested. You just make a simple test-case just for current bug outside the repo.

Re: Fortunately, I don't squash my commits

#35
post #2

Do people out there actually squash commits? Granted, I didn't change many work places in my career, but at no place where I worked people squashed commits. What's even the point of it? It's not like people routinely read the commit history, and when they do, they really would like a complete story, not 20 gargantuan commits that contain 3 years of development.

I religiously squash my commits for each merged pull request.

I seems like madness any other way to me... why have a bigger granularity than a single merge commit?

Re: Fortunately, I don't squash my commits

#36
post #28

Earlier quoted context omitted.

You do keep the history in the branch, it's just out of the way unless you really need it. Also, the method I described has nothing to do with commits. PRs and small commits aren't mutually exclusive.

You have to go dig the branch out of the central repo, though, which is annoying and takes time. That was the price I was thinking of. You're certainly right that PRs and large commits are orthogonal.

Navigate to PR -> Restore Branch -> `git checkout `

How is this annoying or time consuming? It takes less effort than adding, committing and pushing changes.

Re: Fortunately, I don't squash my commits

#37
post #2

Do people out there actually squash commits? Granted, I didn't change many work places in my career, but at no place where I worked people squashed commits. What's even the point of it? It's not like people routinely read the commit history, and when they do, they really would like a complete story, not 20 gargantuan commits that contain 3 years of development.

At my workplace we generate ~150 commits every week or two. There are a lot of trash commits and the history is completely unreadable. I'm sure that's barely any compared to large companies, so I really question the value of commit history unless message guidelines are well enforced.

We go through ~600 commits per day. In my experience, there's nothing worse than looking for when a value was changed from 10 to 100, and finding it in a "Merged from X" commit with the history of why the value was changed from 10 to 100.

I don't often (ever?) browse the history, but I _do_ regularly search the history using tooling, (git log | grep ), and more is more in that case, even if the history isn't perfect.

Re: Fortunately, I don't squash my commits

#38

One obvious requirement for bisect to work is that your code builds on every commit - and so does everybody else participating in the git history. Straw poll - do you enforce this? If so, for literally every commit, or do you use partial squashing to maintain this property? While that's certainly a _desirable_ property, I've never really been concerned if, say, the penultimate commit on a PR failed CI. It feels like…

We use JavaScript at work so even if a part of the application doesn't compile, we usually can run most of the tests. We don't bisect very often and so far, every commit has been good enough for the specific tests we wanted to execute in case of a bisect.

Re: Fortunately, I don't squash my commits

#39
post #8

Earlier quoted context omitted.

Yes they do. And it is frustrating. Specially frustrating when you ar the new guy and the history of the code does not tell what happened.

I don't think having a history full of "Fix the shaver, maybe yaks don't need 6mm trim" with subsequent "Fix shaver again, yaks need as low as a 3mm trim" with some more intermediate commits help understanding what happened either.

yep exactly this. I found early on while having to work with perforce and using timelapse view (git blame but with a nice gui) that lots of intermediary commits like this generate enough noise to discourage even the most determined sleuth from using commit history to solve a crime.

Well scoped and well sized commits, squashed, and in my personal preference rebased, provide a commit history that's segregated on actual tickets/stories/features/fixes that I find are navigatable very far back.

I'd say squash usage is very much case by case. But yeah equating a feature like squash to large commits is a fallacy. It's a useful tool imo that can be misused, but that doesn't mean the tool is "bad".

Re: Fortunately, I don't squash my commits

#40
post #2

Do people out there actually squash commits? Granted, I didn't change many work places in my career, but at no place where I worked people squashed commits. What's even the point of it? It's not like people routinely read the commit history, and when they do, they really would like a complete story, not 20 gargantuan commits that contain 3 years of development.

I do, all the time. I highly recommend others do it too. I like to keep to 1 commit per ticket (even a super large ticket that might take me weeks of development). But having a commit history like the fella in this story is nice too. So what you should do is work in a feature branch. On the day of deployment I'll squash, and cherry pick (in my case to a train). If the deployment goes bad, and my code is at fault, then all that is required to fix it is a single revert.

  If you want to continously deploy to production (with real users using it) you need a process to very quickly revert bad commits from it.  At my last company with hundreds of developers, we would push to prod several times a day.  Each deployment would have several devs changes included.  A clean linear history is essential to making that process work.
Post reply on HN