| ▲ | mikeocool 8 hours ago | |||||||||||||
Constantly rewriting git history with squashes, rebases, manual changes, and force pushes has always seemed like leaving a loaded gun pointed at your foot to me. Especially since you get all of the same advantages with plain old stream on consciousness commits and merges using: git merge --no-ff git log --first-parent git bisect --first-parent | ||||||||||||||
| ▲ | MrJohz 7 hours ago | parent | next [-] | |||||||||||||
I find rebases are only a footgun because the standard git cli is so bad at representing them - things like --force being easier to write than --force-with-lease, there being no way to easily absorb quick fixes into existing commits, interdiffs not really being possible without guesswork, rebases halting the entire workflow if they don't succeed, etc. I've switched over pretty much entirely to Jujutsu (or JJ), which is an alternative VCS that can use Git as its backend so it's still compatible with Github and other git repos. My colleagues can all use git, and I can use JJ without them noticing or needing to care. JJ has merges, and I still use them when I merge a set of changes into the main branch once I've finished working on it, but it also makes rebases really simple and eliminates most of the footguns. So while I'm working on my branch, I can iteratively make a change, and then squash it into the commit I'm working on. If I refactor something, I can split the refactor out so it's in a separate commit and therefore easiest to review and test. When I get review feedback, I can squash it directly into the relevant commit rather than create a new commit for it, which means git blame tends to be much more accurate and helpful - the commit I see in the git blame readout is always the commit that did the change I'm interested in, rather than maybe the commit that was fixing some minor review details, or the commit that had some typo in it that was fixed in a later commit after review but that relationship isn't clear any more. And while I'm working on a branch, I still have access to the full history of each commit and how it's changed over time, so I can easily make a change and then undo it, or see how a particular commit has evolved and maybe restore a previous state. It's just that the end result that gets merged doesn't contain all those details once they're no longer relevant. | ||||||||||||||
| ||||||||||||||
| ▲ | OJFord 7 hours ago | parent | prev | next [-] | |||||||||||||
Until someone merges master into their feature branch rather than rebasing it. (And then that branch later gets merged.) | ||||||||||||||
| ||||||||||||||
| ▲ | OptionOfT 7 hours ago | parent | prev [-] | |||||||||||||
I agree. PR merges for me are bisect points. That's when changes are introduced. Individual commits don't even always build. And I don't rebase or squash because I need provenance in my job. | ||||||||||||||