How I use Jujutsu
I’m used to git, so to adopt Jujutsu (jj), I need to find and memorize
replacements for my common operations. This post exists to record my latest strategies.
Contents
- Configuration
- Fetch from upstream
- Checkout a branch or change
- Push changes
- Rebase all branches on main
- Push everything
- See the state of my local checkout
- See what needs to be pushed
- Create a Github PR
- Delete a branch
Configuration
For now I’m trying to follow https://jj-vcs.github.io/jj/latest/guides/multiple-remotes/, which
recommends that origin be the shared repository that I push my changes to, before sending a PR,
and if there’s a central shared repository that I can’t write to, it’s upstream. This differs from
my git pattern of calling the central shared repository origin whether or not I can write to it,
and using a jyasskin remote if I need somewhere else to push changes. The Github CLI
(gh) prefers the same upstream pattern as jj, but Chromium’s
depot-tools gets confused.
I expect that most of my checkouts, where I’m not the primary editor of the shared repo, will have
the following configuration (in .jj/repo/config.toml):
[git]
fetch = ["origin", "upstream"]
push = "origin"
Fetch from upstream
jj git fetch
Checkout a branch or change
jj edit [name]
OR
jj new [name]
new is safer because edits go into a new change, so I can apply them intentionally. I haven’t
figured out yet which I’ll use in general.
Push changes
Create a branch and push it
jj new main -m 'description'
# Edits
jj b c [name] -r @
jj git push -N # Do I need `-b [name]`?
Set a remote branch to the current change
jj b m [name] -t @
jj git push
Rebase all branches on main
git rebase-update # Using depot-tools
jj rebase -b 'bookmarks()' -d main
The jj version completes immediately, and tells you about all the conflicts. The git version
makes you handle conflicts as it goes.
Push everything
jj git push --tracked
See the state of my local checkout
git with depot-tools: git s, which is a local script consisting of
git map-branches -v
git status
jj log
I might need a shorthand to only show bookmarks and not the whole graph…
See what needs to be pushed
git: git diff origin/branch branch for each potential branch.
jj: jj log and look for *s, representing tracked bookmarks that don’t match their upstream?
Create a Github PR
gh pr create
jj: ??
Delete a branch
git branch -D [name]
jj abandon [name]
Except jj needs to abandon each change individually. Something like jj abandon main::[name] would
probably drop the whole branch, but I need to test that.