Hacker News new | ask | show | jobs
by turboponyy 332 days ago
Can you edit commits by adding on only parts of your "staging" area?

Because that's my workflow. I produce a few focused and semantically coherent commits that I'd like to apply to the codebase, where each keeps the codebase in a working state. I might be working on more than one thing at once, but I know which commit each set of changes should "live in."

An append-only log of commits is decidedly not something I want. Is jj amenable to this?

4 comments

Extremely amenable—my workflow shifted to match your description after I started using jj, because it makes that easier. Conceptually, it’s not “edit commits by adding on only parts of your staging area”, but “edit commits by only moving or splitting parts from another commit”, and since the working copy is a commit, it is handled by that general case instead of being it’s own thing.
It's not quite clear to me what you're talking about, but I think the Megamerge workflow might be something you'd be interested in.

https://v5.chriskrycho.com/journal/jujutsu-megamerges-and-jj...

https://ofcr.se/jujutsu-merge-workflow

jj squash allows you to move changes from a revision to another. Default is your working copy, but there's nothing preventing you from working on several semantic commits and moving changes from your working copy to those commits as you want.

    jj squash --into -r <revset>
Where <revset> is @-, a change id, or perhaps a bookmark name if you want to give a semantic name to your changes.
Yes. You can use jj split to cleave changes out into their own commit, and JJ squash to move changes into another commit