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?
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
* working tree == in progress
* staging area == finished
How do can I split modifications to a single file into multiple commits? (In git)
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.
git commit foo bar/
To commit my changes to foo and bar/* but not baz. Also pairs well with -p.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.
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
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.