News for hackers. Stuff that matters.
Re:Jujutsu Primer by ozim on Friday November 20, 2026 @02:54AM (#50571488)
Have to say staging area is one feature that makes people better programmers. Especially using GUI tooling to pick hunks or discard parts you don’t want to go to a commit was always super useful for me.

I keep running into people who “just commit stuff” and they don’t know what they are doing.

Downside is we are heading into direction where people don’t even read code anymore so O might be just old man screaming at the clouds or agents.

Re:Jujutsu Primer by KingMob on Friday November 20, 2026 @03:08AM (#50571600)
Think of it this way: you still have a staging area in jj, but now it's a commit instead of something unique and separate. There's zero obstacle to picking and discarding hunks with jj.
Re:Jujutsu Primer by ozim on Friday November 20, 2026 @04:00AM (#50572014)
I do that for stash, I do not use stash for me it is commit or discard.
Re:Jujutsu Primer by IshKebab on Friday November 20, 2026 @05:19AM (#50572654)
Here's my current workflow:

1. I write some code.

2. I realise it makes sense to commit as two commits.

3. I stage changes for the first commit & commit it.

4. I stage the remaining changes and commit those.

How would that work in JJ? I guess you do things in a different order somehow?

Re:Jujutsu Primer by dieortin on Friday November 20, 2026 @05:24AM (#50572692)
You would just use jj split to break the working commit into two, choosing which parts to put in which commit
Re:Jujutsu Primer by IshKebab on Friday November 20, 2026 @02:06PM (#50580125)
Ah right so I can say "jj put this change into a new/existing commit before this one"?
Re:Jujutsu Primer by ssivark on Friday November 20, 2026 @05:38AM (#50572797)
[delayed]
Re:Jujutsu Primer by nchmy on Friday November 20, 2026 @05:44AM (#50572847)
Someone already said this, but you just use jj split. Either split the whole file or use interactive mode to split the exact lines. You could also use squash if you want to move it to an existing revision/commit.

It's vastly more efficient and ergonomic - no staging area to think about, remember, stumble over, etc.

It's all dead simple if you use jjui - don't even need to learn any jj syntax

Re:Jujutsu Primer by orbisvicis on Friday November 20, 2026 @09:21AM (#50575019)
For me:

* working tree == in progress

* staging area == finished

How do can I split modifications to a single file into multiple commits? (In git)

Re:Jujutsu Primer by ozim on Friday November 20, 2026 @12:13PM (#50578228)
You stage hunks, git add —patch which is not convenient so better to use GUI tools.
Re:Jujutsu Primer by BeetleB on Friday November 20, 2026 @10:26AM (#50576044)
> Think of it this way: you still have a staging area in jj, but now it's a commit instead of something unique and separate.

Indeed. One nice thing about this is you can have a staging area for the staging area (repeat ad nauseum). It's not that unusual that I treat a commit as the staging area, and then I want to do something experimental on top of it, and make a new commit on top of my staging area and try things out there - ultimately to squash into my main staging commit.

In my last job I gave a presentation on jj and I hammered this point. I said it's like git but with everything version controlled. The index/staging is version controlled. The stash is version controlled. Technically even things like setting/unsetting bookmarks, commit descriptions etc are version controlled.

Re:Jujutsu Primer by wmedrano on Friday November 20, 2026 @03:35AM (#50571822)
I think jj is pretty good at this. You can use `jj squash -i` to move hunks to parent commit or `jj split to partition hunks into separate commits.
Re:Jujutsu Primer by yjftsjthsd-h on Friday November 20, 2026 @03:42AM (#50571881)
I effectively skip staging by just doing e.g.

  git commit foo bar/
To commit my changes to foo and bar/* but not baz. Also pairs well with -p.
Re:Jujutsu Primer by throawayonthe on Friday November 20, 2026 @04:01AM (#50572020)
if anything i think jj encourages you to commit selectively by doing jj squash <options> / jj split and by enabling you to edit commits with no worry
Re:Jujutsu Primer by breppp on Friday November 20, 2026 @06:07AM (#50573042)
In jj you create a new commit for the staged parts, you can name it "wip: foobariating", and then the gui tooling allows you to move files between both commits, for me it's the equivalent of a staging area/stash that you can name
Re:Jujutsu Primer by rbehrends on Friday November 20, 2026 @06:56AM (#50573492)
To each their own, but I always saw the staging area as an anti-pattern that also needlessly complicated git's mental model.

With the staging area, you don't even know if the commit builds if you commit selectively, and manual adding is error-prone.

The traditional "clean" way has been to stash unwanted changes temporarily, then commit the rest.

Re:Jujutsu Primer by coffeeindex on Friday November 20, 2026 @12:40PM (#50578728)
> With the staging area, you don’t even know if the commit builds if you commit selectively, and manual adding is error-prone.

I get conceptually why it’s desired to have things build properly on every commit but I just haven’t seen people actually make use of that. In my team’s current code base, we have the commits in a given PR auto-squash down into one commit which I’ve liked quite a bit

Re:Jujutsu Primer by nixpulvis on Friday November 20, 2026 @02:13PM (#50580238)
It's the lazy and pragmatic solution for those who aren't really comfortable with git / VCS.