Rebase is not only useful, but <i>necessary</i> for a distributed VCS to be useful. To be precise, you need to be able to create new commits from old ones using the VCS itself, and if you can do that, you can also rebase.<p>One of the <i>major</i> reasons I use git for source control whenever I can is that 100% of its features are available at any time for me to use in any way I wish. Rebase allows me to make commits for whatever reason I want at any time, and it's useful because losing committed data is <i>really hard</i>.<p>When I'm writing code, I put very little effort into how to structure my changes into commits; That's done when I'm preparing a PR or a patch series, when I'm out of the coding mindset and in the "how do I make this reviewable" mindset. When you're contributing to a project, these are two separate tasks that require different approaches. Any false starts and experiments should be documented and expanded on in this phase, because you're communicating with other people. Pushing a series of crappy "asdf" commits on people because "it documents the development process" is lazy and rude.<p>A tool that requires me to have perfect commits immediately is useless, because getting commits perfect the first time you actually need to commit is not possible.
Where are the author’s raw notes, false starts, and ultimately discarded segments for this article?<p>Removing uninteresting cruft before publishing is a good idea, and rebase is a good tool for achieving that.
Sigh.<p>Rebase is very useful:<p>* pre-processing step to a merge. The developer can see that the merge to main will be successful.<p>* when the branch has cherry picked commits from main, those cherry picks will disappear from the feature branch's commit list.<p>* rebase also includes the ability to combine commits (get rid of all those WIP commits)<p>* rebase allows reorder of commits.<p>rebase is so so much more than just rearrange commit pointers in some "bad" ways.<p>Failure to include functionality just invites my old fallback when a rebase fails badly.<p>git checkout main;<p>git checkout -b new_branch;<p>git diff -R old_branch | git apply;<p>git add -A ;<p>git commit<p>Removing a tool just invites developers to work around the gap.
> if you are using rebase as intended, that means you are keeping private branches. Or, to put it another way, you are doing siloed development.<p>My average PR represents maybe an afternoon of work before it's reviewed and merged and shipped. With such short-lived branches, siloing isn't a big deal.<p>I'd suggest that shipping multiple times a day renders rebase's harm pretty irrelevant.<p>But if we flip that around, are we shipping multiple times a day because we lack tooling and workflows for non-silo'd development? We ship PRs quickly because a long lived PR is hard to maintain and keep up to date. If that wasn't a problem, would we ship less often?
I too have thought about this stuff. In many instances, the correct solution depends on the context of the work being done. Are many people working on interrelated parts of the same project? Or, is there a small group of people jumping from one project to the next in any given day with multiple people collaborating in branches at the same time?<p>> 3.0 Rebase encourages siloed development<p>You need a strong culturally enforced habit of "commit early, commit often ... rebase early, rebase often, push early push often" with all development happening in branches that are visible to everyone (GitHub, GitLab etc) to avoid this.<p>I conceptually like a main branch with a clean straight-line history with no merge commits and clear commit messages. It takes discipline. The discipline is helped by a cultural environment where anyone can request changes in any PR, where teams, not individuals, own projects, where clarity of the commit message is equally important as the code, and where is a strong preference for short-lived branches and small PRs.<p>I also recommend opening a PR as soon as a single commit has been made in a branch <i>and</i> announcing the PR in a dedicated channel so everyone has a chance to follow the development.<p>This kind of thing is not going to work in every type of project in every organization, but I have developed a preference for it.
I'm definitely on the side of rebase being much better in most cases. <a href="https://blog.carbonfive.com/always-squash-and-rebase-your-git-commits/" rel="nofollow">https://blog.carbonfive.com/always-squash-and-rebase-your-gi...</a>
We discuss this in detail with Richard on next week's episode of The Changelog podcast.<p><a href="https://changelog.fm" rel="nofollow">https://changelog.fm</a>