Sorting Messy Commits Into Clean History with Jujutsu
A developer outlines a workflow in Jujutsu (jj) for producing reviewable, well-scoped commits without enforcing discipline throughout feature development. Rather than maintaining strict commit hygiene as code is written, the approach embraces a sprawling ‘everything commit’ during active work, then reorganizes it at the end. Built-in helpers like jj absorb and jj squash -i fall short: absorb infers commit ownership from file history rather than logical intent, and interactive squash can trigger painful merge conflicts when boundaries are blurry.
The technique works by first scaffolding an ideal commit history as empty placeholder commits (red, blue, etc.), each representing one logical changeset. All the messy work-in-progress commits are then squashed together into a single bucket, and jj squash -i pulls hunks out of that bucket and into the appropriate placeholder. The process repeats until the bucket is empty and each placeholder holds only its intended changes.
The author argues this beats jj split, which forces redoing work if a hunk is misclassified, and beats squashing as you go, which risks breaking previously sorted commits. The main caveat is that intermediate commits aren’t guaranteed to compile, which may rule out the approach for projects with strict bisection requirements.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.