by xnorswap · 1y ago · 0 comments
I'm fine with the history capturing what has actually happened. a Git history isn't something that is supposed to be admired as if it were a work of art.
The git history is the scaffolding, not the cathedral itself.
Even the source code isn't the cathedral, that's more super-structure. The product is the goal.
That way lies madness.
Code that takes a minute to write takes ten minutes to understand. Code is first and foremost for humans to understand, before it is for machines to execute. Otherwise there would be no need for comments, or sane names for functions. Or commit messages. Please be considerate to your readers.
So instead of:
* Change 1
* Fix typo
* Change 2
* Another typo
* Change 3
* That didn't work
* Ops, I did it again
* Revert Change 3
* Change 3 (final)
You'll merge: * Change 1
* Change 2
* Change 3
Which is much better, particularly if you have hundreds of developers working on the same codebase.And it is very easy to do that using `git rebase -i`.
(I don't see the need for a GUI)
I can also see value there if you're not squashing commits at the PR level. I prefer just squashing commits so main becomes:
- Feature 1
- Feature 2
- BugFix 1
- Feature 4
etc.The individual branches have the "dirty" history which can be useful, and main is kept neat by having feature of fix-level changes which are quality controlled through gated-commits.
If you had to work on long-running feature branches which were more of a free-for-all so /branches/feature effectively becomes your "main" then I could see much more of an argument for re-writing history of individual contributors before merging into that feature branch.
I'd still argue you should just set up proper quality control on the feature branch and squash commits going into that, but that's the kind of overhead that can frustrate some teams, so I can better understand now the desire for a half-way cleaning between squashing and the full dirty history.
To see a "clean" history, I can always use log options like git's -first-parent. It works great and doesn't delete history.
During development of a thing it should be desirable to be able to handle/test just whatever the current thing is and clean up afterwards if necessary, without having to completely drop ability to use git. But this can impact later bisects - having temporary printf("fuck sadjkoisajhdfo")s spamming outputs, project entirely not building on a configuration that wasn't cared about at the moment (or worse, build successfully, but function off enough that it's not obvious that the commit was not intended to be touched).
And then there's the general thing of having a feature that you had been working on, but want to move it to some other branch. Or you committed things out of order and the committed order doesn't actually build in the middle. Or you didn't commit some file/change and thus have a sequence of ten completely-non-sensical non-functional commits.
The inverse question deserves asking - why would you want to leave in your primary commit history things not meant to ever be looked at?