Hacker News new | ask | show | jobs
by chousuke 1773 days ago
Rebase is not only useful, but necessary 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.

One of the major 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 really hard.

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.

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.

3 comments

Agreed. And I very much disagree with this paragraph:

> When a developer can go back to the individual check-ins leading up to the current code, they can work out the answers to such questions using only the level of personal brilliance necessary to be a good developer.

When I have to investigate past commits, I hate it to have to dig through a history of WIP commits containing code that didn't make it into the final version.

Of course it's also difficult to dig through a single commit with hundreds or thousands changed lines of code. But when a single commit includes a proper description and an issue reference, it much easier to investigate the developer's full intention than from multiple WIPs.

Realistically, a single commit is not going to contain hundreds of thousands of lines of changes unless they're generated code or something.

I'm not advocating that you should merge branches by squashing all commits into one lump; that's definitely wrong. I think in terms of patch series, where each patch is a single commit that does something, and each feature is a series of patches consisting of stand-alone refactorings, bug fixes and new APIs required to implement the final feature.

But how I actually end up with that clean set of 1-n final commits in a PR or mailing list submission is no-one's business but mine.

+1 rebase and merge aren't weird things that git does, they are fundamental to any version control system. They are pretty much necessary for collaboration or if you want to edit history.
Completely agree. Rebasing is absolutely necessary and useful when multiple developers are committing different fixes all the time.