Jujutsu VCS (jj)
Jujutsu VCS Introduction and Patterns | Kuba Martin
Splitting a changeset into two changesets
jj split -i
[q to quit, c to commit]
The changes you choose go to the first changeset, the second go to the next changeset.
This operation alone is easier to do in jj vs in git.
Reordering changesets
jj rebase -r <changeset>
Pushing the new bookmark (i.e. a branch in git)
jj git push --allow-new
Undo a change
jj undo
Untrack a file from the working copy
Added a file to gitignore, but overzealous jj already added it to the working copy? "Unstage" it (remove from the working copy) by running:
jj file untrack <file>
Track a branch with a remote branch
When working with a preexisting git repo, master/main is not automatically tracked with the remote branch. So it is not automatically updated when you run jj git fetch. You can set up that tracking by running:
jj bookmark track master@origin
Move changes from the working copy to a previous commit
If you think of the working copy as the index, you can create a new "commit" by running
jj new -B -m "<message>"
Then move all the changes to the commit we created, or pass in an optional file argument:
jj squash <file>
Or select the hunks by running:
jj squash -i
git reset --hard HEAD
jj restore --working-copy --from=@-
Push branches related to a PR stack
[revset-aliases]
‘pr_stack’ = ‘trunk()..@ & bookmarks() ~ bookmarks(“wip-“)’
Don't push the working copy / wip code
[git]
# Prevent pushing work in progress or anything explicitly labeled "private" private-commits = "bookmarks("wip-") | description(glob:'private:*')"
Add a new parent to the merge commit
From https://ofcr.se/jujutsu-merge-workflow
@ - current merge commit
jj rebase -s @ -d '@-' -d {{new parent change id}}
Rebase all the parents of the current merge commit to the latest trunk commit
From https://ofcr.se/jujutsu-merge-workflow
jj rebase -s 'roots(trunk()..@)' -d 'trunk()'