Hacker News new | ask | show | jobs
by tbrownaw 3552 days ago
Git allows you to do violence to history: it's very much possible to commit regularly as you work, and then rearrange those commits later to be more logical.

I have no idea how easy this is, but I've seen plenty about how horribly impolite it is when you rearrange any history that other people have seen.

2 comments

It helps if you keep unrelated code in separate commits. That way all you have to do is rearrange and merge commits. It gets more complicated if you have to split commits. I've been wanting to make a GUI for this purpose that allows you to drag and drop hunks/commits. Essentially a GUI for interactive rebase.

And yes, don't change history others have seen, but do it as much as you need locally.

EDIT: typo/clarity

what this really means in practice is "never branch off anything but master"

which is ok for maintenance bug fixes, but precludes a lot of interesting workflows involving speculative work, late binding the order of commits, early integration branches, etc.

my workaround for this usually just involves doing what i want up front, and then abandoning git for the merge process (since my history is polluted by false conflicts), constructing diffs and applying them as single commits against master.

which works, its just a bit silly

There's nothing stopping you from using an amend-commit and just adding every change as you go, as long as you never push to other people. That's the exact veneer that gitless provides, albeit it renames what some of the commands do.