News for hackers. Stuff that matters.
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.