# jj — git without the staging area Jujutsu is a VCS that speaks git on the wire and something much simpler on your side of it. Installed here as **`jj 0.44`**, config at `~/.config/jj/config.toml`, shell aliases in `~/.dotfiles/config/jj.zsh`. Terminal card: **`jj-cheat`** — sections `setup flow model words repo see work move book git branch undo fix rev xlat mine`. **`jj-cheat setup`** is the one to read first. Short alias list: **`jjhelp`**. Full 40-page guide: `NetrunnerVault/04Tools/jj-field-guide/jj-field-guide.pdf`. ## Setup — from a folder to GitHub Do this **once per repo**. After it, you only ever run the four-move ritual below. ```sh cd ~/git/thing jj git init # .jj + .git, colocated jj git remote add origin git@github.com:USER/repo.git # where GitHub is jj git fetch # learn what GitHub has jj bookmark track main@origin # marry your main to theirs — ONCE, ever jj-commit "vault: first import of notes" # seal your work jj bookmark set main -r @- # move the sticky note onto it jj git push # send it ``` - **`jj git init`** — turns this folder into a jj repo. `--colocate` is the **default** in 0.44, so `.git` sits beside `.jj` and every git tool (lazygit, `gh`, Obsidian plugins) keeps working. Backing out is `rm -rf .jj/`. - **`jj git remote add origin URL`** — check it with `jj git remote list`. - **`jj bookmark track main@origin`** — the one-time marriage of **your** `main` to **GitHub's** `main`. It needs `main@origin` to exist, so fetch (or clone) first. Running it twice is harmless — jj just says it is already tracked. Answer: `Started tracking 1 remote bookmarks.` - **`jj-commit "msg"`** — this machine's wrapper: `jj commit` plus `Commit-Date` and `Commit-Host` trailers. Plain `jj commit -m "msg"` works identically without the trailers. - **`jj bookmark set main -r @-`** — the step git did invisibly. `@-` because `jj commit` left `@` empty on top. - **`jj git push`** — sends tracked bookmarks that moved. **If GitHub's repo is empty** there is no `main@origin` to track yet. Create it with **no** README, **no** .gitignore, **no** license, then: ```sh jj git init jj git remote add origin git@github.com:USER/repo.git jj-commit "Initial commit" jj bookmark create main -r @- jj git push -b main # -b creates it on GitHub AND tracks it ``` A plain `jj git push` refuses to invent a bookmark on GitHub — that is the safety net that stops a half-baked branch escaping: ```text Warning: Refusing to create new remote bookmark main@origin Hint: Run `jj bookmark track main@origin` and try again. Nothing changed. ``` There is no `--allow-new` flag in jj. Naming it with `-b main` is you saying **yes, publish this one**, and jj tracks the pair for you. From the second push on, plain `jj git push` carries `main`. **If the repo already lives on GitHub**, let jj make the local copy and tracking comes free: ```sh jj git clone --colocate https://github.com/USER/repo.git Thing ``` ```text bookmark: main@origin [new] tracked Setting the revset alias `trunk()` to `main@origin`. Parent commit (@-): qtvtpwxm f34fe73b main | Initial commit ``` That `[new] tracked` line **is** the tracking setup — you never type `jj bookmark track` on this path. **If you already have the folder and a git remote**, jj slides in without disturbing anything; history is imported and uncommitted work becomes `@`, nothing is stashed: ```sh cd ~/dotfiles jj git init printf '\n.jj/\n' >> .gitignore # jj does NOT ignore itself; git would track .jj/ jj bookmark track main@origin jj st # your uncommitted files are already in @ ``` **Set your identity once per computer, before the first commit** — that avoids the `author will stay …` warning you get for changing identity mid-repo: ```sh jj config set --user user.name "DAEMON" jj config set --user user.email "you@example.com" jj config list user ``` > **Checkpoint.** `jj bookmark list --all-remotes` — three lines, all quoting the **same** change ID, means fully published. `main:` is your note, `@git:` is the colocated `.git`'s copy (bookkeeping), `@origin:` is GitHub's copy. Indented under `main` means the pair is tracked. ## The ritual — four moves, every publish ```sh jj st # 1. look: what did I change? jj commit -m "update: ..." # 2. seal it with a message jj bookmark set main -r @- # 3. move the sticky note onto it jj git push # 4. send it to GitHub ``` Move 3 is the one git did for you invisibly. Skip it and push **succeeds, changes nothing**, and warns in a line that is easy to walk past: ```text Warning: No bookmarks/tags found in the default push revset: remote_bookmarks(remote=origin)..@ Nothing changed. ``` Set the bookmark and push again, and both commands say what they did: ```text Moved 1 bookmarks to kmpmlqyt 5a24a49b main* | nmap: add UDP top-100 sweep Changes to push to origin: bookmark: main [move forward from 2adbd45d331b to 5a24a49be1b7] ``` The `*` after `main` means **ahead of GitHub**. After the push it disappears. `move forward` means a clean fast-forward — nothing was overwritten. > Stop running `jj commit` **after** the bookmark move. Moving a bookmark relabels; it creates nothing that needs committing, so the second commit just seals an empty change. Commit once, move the note, push. Three moves, not five. ## The one idea The working copy **is a commit**, called **`@`**. It already exists before you type anything, and every edit you make lands in it automatically — jj snapshots the tree at the start of every command. There is no index, so there is no `git add`, no `git stash`, and nothing to forget to stage. The question stops being "what do I stage and commit?" and becomes "which commit am I editing right now?" — the answer is `@` until you move it with `jj new` or `jj edit`. **`@-` is the commit right below you.** History is a stack: `@` on top, `@-` its parent, `@--` one further down. `jj commit` seals your work and opens a fresh **empty** `@` on top — so one second after committing, the work you just finished lives at `@-`. That is why every bookmark command says `-r @-` and never `-r @`. ```text before: @ <- your edits, unsealed after: @ <- new, EMPTY, ready for tomorrow o <- yesterday o <- your sealed work = @- o <- yesterday = @-- ``` **Bookmarks never move by themselves.** A bookmark is a sticky note with a name, stuck to exactly one commit. `main` is a sticky note. Nothing lives "inside" it and you are never "on" it. You commit ten times and it still points at the old commit. GitHub reads `main`'s sticky note, so until *you* move it, GitHub keeps seeing last week's work. Every commit carries **two ids**: a **change ID** (letters, e.g. `kmzwqxpl`) that is stable across every rewrite, and a **commit ID** (the git hash) that changes whenever the commit does. Use the change id anywhere you would have copied a sha — it survives describe, squash and rebase. > jj splits "record my work" from "publish my work" so nothing ever leaves your machine as a side effect. The price is one extra command. The payoff: every commit, bookmark move, fetch and mistake is an operation in `jj op log`, and `jj undo` reverses any of them. Rewriting is the normal mode of work, not surgery — amend a commit in the middle of a stack and every descendant is rebased for you. ## The words | term | what it means | |---|---| | `change` | one saved snapshot of the whole tree — git's "commit" | | `change ID` | letters (`ptxpotvt`); survives every rewrite. Prefer it. | | `commit ID` | hex (`d3020f8c`); the git hash, changes with the content | | `@` | the working-copy commit — your files, right now | | `@-` / `@--` | parent / grandparent of `@`. Sealed work lands at `@-`. | | `bookmark` | named sticky note on exactly one change. git's branch. | | `main` | **your** note, on this machine | | `main@origin` | jj's record of where **GitHub's** main is — a different note | | `tracked` | the one-time marriage of `main` to `main@origin` | | `revision` / `-r` | "which change?" — `@`, `@-`, a change ID, or a bookmark name | | `operation` | any command that touched the repo; listed in `jj op log` | | `colocated` | `.jj/` and `.git/` side by side, so git tools keep working | The picture everything reduces to — two sticky notes, one cloud: ```text @ <- your desk, right now | o <- main your note: sealed work = @- | o <- main@origin what GitHub still has (behind) | o older history push = make theirs match yours ``` When a command confuses you, ask: **which sticky note is it about, and which commit should that note point at?** > In a colocated repo `git status` says "not currently on any branch". That is **normal here**, not damage — read `jj bookmark list` instead. ## Reading the repo - **`jj`** — bare, prints a one-line hint and then the log. `ui.default-command` is **not** set here; silence the hint with `jj config set --user ui.default-command log`. - **`jj st`** — status: what changed in `@`, conflicts, bookmarks pointing here. `A` = added, `M` = modified. - **`jj log -r 'all()'`** — everything; `-n 20` limits, `--reversed` flips, `-p` adds patches, `--stat` a histogram. - **`jj show `** — one commit, metadata plus diff. - **`jj diff --from A --to B`** — any two points; `--git`, `--color-words`, `--name-only`, `--stat`. - **`jj bookmark list --all-remotes`** — where every sticky note is, yours and GitHub's. - **`jj git push --dry-run`** — rehearse a push, touch nothing. - **`jj evolog -r `** — every version *that change* has been, before each amend and rebase. git has no equivalent. - **`jj interdiff --from A --to B`** — the diff between two diffs: what actually changed when you rewrote. - **`jj file annotate `** — blame. **`jj file list -r `** — tree listing. Read `jj st` as a sentence — "`@` holds a modified `note.md` and has no description yet; the change below it is the last thing I sealed": ```text Working copy changes: M note.md Working copy (@) : pqtwmqkw 6fba7d6c (no description set) Parent commit (@-): ykywxwny 5a23fea5 notes: expand field notes ``` Read `jj bookmark list --all-remotes` as a diagnosis: all three lines quoting the same change ID means fully published; `@origin` quoting an older ID marked `(behind by 1 commits)` means you moved the note but have not pushed; `main` itself quoting an old ID while `jj log` shows newer work means you committed but forgot the move. ## Making changes - **`jj new`** — a fresh empty change on top of `@`. `jj new ` starts elsewhere; `jj new A B` creates a merge. - **`jj describe -m "msg"`** — set `@`'s message. No `--amend`: editing a commit is the ordinary thing. - **`jj commit -m "msg"`** — describe `@` and open a new change on top. The git-commit-shaped shortcut. - **`jj squash`** — fold `@` into its parent. This is `git commit --amend`. - **`jj squash -i`** — choose hunks. This is `git add -p`. - **`jj squash --into `** — fold into any commit, not just the parent; `--from` pulls the other direction. - **`jj absorb`** — scatter `@`'s edits into whichever ancestors last touched those lines. This is `git commit --fixup` plus autosquash, without naming anything. - **`jj split -i`** — cut `@` in two; `-p` makes them parallel siblings instead of a stack. - **`jj diffedit -r `** — open a diff editor and rewrite a commit's content directly. - **`jj restore --from `** — take file contents from another revision. - **`jj edit `** — make an existing commit the working copy and keep editing it in place. - **`jj next`** / **`jj prev`** — walk the stack; `-e` to edit rather than sit on top. - **`jj abandon `** — **drop a change.** Descendants rebase onto its parent. Recoverable with `jj undo`. The word `(empty)` on the `@` line is the success signal after a commit — your edits were sealed below and you are standing on a clean slate: ```text Working copy (@) now at: qwvxwwts 97614bab (empty) (no description set) Parent commit (@-) : ykywxwny 2524f49b notes: expand field notes ``` > **Saved here is not visible on GitHub.** A commit lives only on this machine until the `main` note moves onto it and you push. Stop after `jj commit` and GitHub shows the old files, with zero warnings. That is the number-one jj gotcha, and why the ritual has four steps. ## Commit messages Four ways, all producing subject / blank line / body: ```sh jj commit -m "nmap: add UDP top-100 sweep" # one line, the everyday case jj commit -m "subject" -m "body para" # each -m becomes a paragraph jj commit -m "$(cat /tmp/commit-msg.txt)" # the whole file, newlines and all jj describe -r @- --stdin < /tmp/commit-msg.txt # rewrite an old message from a file jj commit # no -m: opens $EDITOR on a template ``` The template's `JJ:` lines are comments and get stripped. Save it **empty** to abort — jj leaves the change untouched and prints `Nothing changed.` The same flags work on `jj squash -m` and `jj split -m`; `--editor` forces the editor open even when `-m` was given. jj refuses to push a change whose message is empty, so give every commit a few honest words. **`jj-commit`** is the local wrapper — the same workflow plus an ISO timestamp and the machine hostname: ```sh jj-commit "feat: add parser" # commit @ and start the next change jcm "feat: add parser" # short alias for the same command jj-commit --push "feat: add parser" # commit, then jj git push --change @- jcmp "feat: add parser" # short commit-and-push alias jj-commit --dry-run "feat: add parser" # preview message and actions only jj-commit # no message: read it from stdin (Enter, then Ctrl-D) ``` ```text feat: add parser Commit-Date: 2026-09-01T21:39:15+01:00 Commit-Host: omarchy ``` There is deliberately no `--add`: jj snapshots the working-copy commit automatically. After `jj commit` the completed change is **`@-`** and `@` is the fresh empty child, so `--push` runs `jj git push --change @-` — an auto-named `push-` bookmark, **not** `main`. To publish `main` it is still `jj bookmark set main -r @-` then `jj git push`. Related shell helpers: **`commitdate`** prints the same ISO date format, **`commithost`** prints the hostname, and **`datestamp`** prints a filename-safe timestamp. The Git twin is `git-commit` (`gcm`), with explicit `--add` and `--push` options. ## Bookmarks (jj's branches) Nothing is ever "checked out". A bookmark is a pointer you move deliberately — it does **not** follow you as you commit. Moving one **never** changes your files; it relabels, and `jj undo` reverses it. - **`jj bookmark set -r `** — create or move, one verb. The only one in the ritual. - **`jj bookmark create -r @-`** — create only; errors if the name exists. - **`jj bookmark move --to `** — move an existing one. - **`jj bookmark list`** — bookmarks and targets; `--all-remotes` for the tracking picture. - **`jj bookmark rename old new`** — rename the local note. - **`jj bookmark track NAME@origin`** / **`untrack`** — follow or stop following a remote bookmark. - **`jj bookmark delete `** — **deletes, and propagates that deletion on the next push.** - **`jj bookmark forget `** — forgets it locally only; the remote keeps its copy. - **`jj tug`** — **does not exist.** It is not a jj subcommand and nothing in `~/.config/jj/config.toml` defines it as an alias, so the `jtug` shell alias fails. The portable move is always `jj bookmark set NAME -r @-`. (An older cheat sheet taught `jj tug`; that is what made bookmarks confusing.) `jj bookmark set main -r @-`, word by word: `jj` the tool · `bookmark set` "put a sticky note somewhere", creating it if new · `main` which note · `-r` "on revision …" · `@-` the commit below `@`, which is your sealed work. First time it answers `Created`, afterwards `Moved`. Three questions everyone asks: **"Am I on main right now?"** — no, that question does not exist in jj; you stand on commits and `main` is a label. **"Does moving a bookmark change my files?"** — never. **"I set it to the wrong commit"** — `jj undo`, or just set it again with the right `-r`. Working with no bookmark at all is fine: anonymous heads still show in `jj log`, so there is no "you are on the wrong branch" state to be caught by. > `delete` means "gone **everywhere**" — the deletion travels to GitHub on your next push. `forget` means "stop tracking it here, leave GitHub alone." If unsure, you want `forget`. ## Push `jj git push` does not mean "upload my latest work". It means: **for every tracked sticky note that moved, make GitHub's copy match mine.** If no note moved there is nothing to say, and push does nothing — successfully and quietly. - **`jj git push`** — tracked bookmarks that moved. - **`jj git push -b main`** — just this one, creating it on GitHub if it is new (and tracking it). - **`jj git push --dry-run`** — rehearse; touches nothing. - **`jj git push --change @-`** (`-c`) — invents `push-` and pushes that. The PR flow; it never touches `main`. Push `@-`, not `@` — right after `jj commit` the working copy is **empty**. - **`jj git push --named feat=@-`** — name it and push it in one move. - **`jj git push --all`** — every bookmark and tag, including new ones. - **`jj git push --deleted`** — propagate local bookmark deletions to GitHub. - **`jj git import`** / **`export`** — resync manually if a raw git command moved things underneath. A bookmark GitHub has never seen is **not** allowed to leave on a plain `jj git push` — you must name it the first time with `-b NAME` (or `--change` / `--named`), which also tracks the pair. Commits with empty descriptions are **refused** unless you pass `--allow-empty-description`. `track` and `set` look like cousins. They are not: **`jj bookmark track main@origin`** is plumbing you run once, ever; **`jj bookmark set main -r @-`** is a daily move, forever. ## Fetch and sync There is no `jj pull`, on purpose — fetching and rewriting your work are separate decisions: ```sh jj commit -m "wip: checkpoint before sync" # 1. never sync over a messy desk jj git fetch # 2. download only — jf fetches all remotes jj log # 3. LOOK before merging anything jj rebase -o main@origin # 4. replay my stack onto GitHub's newest jj bookmark set main -r @- jj git push ``` Fetch updates `main@origin` and **never edits your files**, so there is no "your local changes would be overwritten" refusal. Two healthy answers: `Nothing changed.` (usual on a one-machine repo) or `bookmark: main@origin [updated] tracked`. `git.auto-local-bookmark` is **not** set here, so a fetched remote bookmark does not become a local one on its own — that is exactly why `jj bookmark track main@origin` is a real setup step. In `jj log`, `main@origin` sitting directly below your work means you were simply ahead — nothing to integrate. > **Never plain `git pull` in a colocated repo.** It goes behind jj's back, can jam the `.git` into a merge state, and can silently combine two versions of a file. The jj spelling is `jj git fetch`, look, `jj rebase -o main@origin`. **`main??` — both sides moved.** jj is refusing to guess, and nothing is lost: ```text main (conflicted): - pyuuvvoq af1de6ad tmux: add pane, session and zoom cheats + tkqsrolo 65bc137b nmap: add -T4 to fast sweep + lxmrmuxm fd61cf23 nmap: bump fast sweep to --min-rate 5000 @git (behind by 1 commits): tkqsrolo 65bc137b nmap: add -T4 to fast sweep @origin (behind by 1 commits): lxmrmuxm fd61cf23 nmap: bump fast sweep to --min-rate 5000 ``` The note used to sit on the `-` line; now there are two `+` candidates, yours and GitHub's. Two clean exits: ```sh # keep BOTH (the usual choice) jj rebase -o main@origin jj bookmark set main -r @- jj git push # GitHub WINS — your commits stay in jj log for salvage jj bookmark set main -r main@origin jj new main ``` ## Side branches In jj you do not need a branch to start working — you only need a bookmark at the moment GitHub has to see it. ```sh jj new main # 1. clean empty @ sitting on main jj commit -m "draft: crazy idea" # 2. seal it jj bookmark create idea -r @- # 3. stick a new note on it jj git push -b idea # 4. first push needs -b (creates + tracks) ``` Updating it later is the pattern you already know with a different name in the middle: `jj commit`, `jj bookmark set idea -r @-`, `jj git push`. One pattern, every bookmark. Switching is just choosing what to stand on next — `jj new main` or `jj new idea`. Files switch instantly. Uncommitted edits live in `@`, and `jj new` leaves that `@` behind as its own change, retrievable from `jj log`. **This is why jj has no stash.** Done with it: `jj bookmark delete idea` then `jj git push --deleted`. The commits stay in `jj log` — only the label goes. Cleaning a stray `push-xxxx` branch is the same move: find it with `jj bookmark list --all-remotes`, `jj bookmark delete push-utnprnylpqwx`, `jj git push --deleted`. ## Moving history `jj rebase` takes a scope and a destination: | flag | scope | |---|---| | `-r ` | that revision only; its descendants stay where they are | | `-s ` | that revision **and** its descendants | | `-b ` | the whole branch containing it | | `-o` / `-d ` | destination — repeat `-o` to build a merge | | `-A` / `-B ` | splice in after / before a revision | - **`jj rebase -s @ -d main`** — the everyday one: move my stack onto a bookmark. - **`--skip-emptied`** — drop commits that became empty because upstream already has them. - **`jj duplicate -r X -o Y`** — cherry-pick that keeps the original too. - **`jj parallelize A B`** — turn a chain into siblings. **`jj simplify-parents`** — drop redundant merge edges. - **`jj revert -r X -d @`** — apply the reverse of X as a new commit. - **`jj arrange`** — interactive graph surgery. **`jj bisect run -- cmd`** — automated bisect. **`jj fix`** — run formatters across revisions. Merging a feature, linear (`jj rebase -b feat -d main`, `jj bookmark move main --to feat`, `jj git push -b main`) or as a real merge commit (`jj new main feat -m "merge: feat"`, `jj bookmark move main --to @`). `trunk()` and its ancestors are **immutable** by default: jj refuses to rewrite them. `--ignore-immutable` overrides, deliberately. > There is no `--continue` and no `--abort`. A rebase that hits a conflict still completes; the conflict is stored inside the commit and waits for you. `jj undo` is `git merge --abort` — and unlike git it still works **after** the merge succeeded. ## The operation log Every mutation of the repo — commit, rebase, fetch, abandon, even a working-copy snapshot — is an **operation**, and the whole repo is versioned by them. This is repo-wide; git's reflog never covered you like this. - **`jj op log -n 10`** — the footage, newest first; the `args:` line names the exact command you ran. - **`jj op show `** — what one operation changed. - **`jj undo`** — reverse the last operation, including a rebase or a fetch. **`jj redo`** — undo the undo. - **`jj op restore `** — put the entire repo back to that moment; itself undoable. - **`jj op diff --from A --to B`** — repo state between two operations. - **`jj --at-op= log`** — look at the past without moving to it. - **`jj op abandon --until `** — **prune operation history. This one really deletes.** ```text Undid operation: 660868458073 (2026-08-28 19:08:21) point bookmark main to commit 51bbfe901b871d1a1653ee921abaf5e0f7ec14d8 Restored to operation: 0298bbd82c8f (…) push bookmark main to git remote origin ``` Moved the wrong bookmark? `jj undo`. Rebase made a mess? `jj undo`. Fetched something weird? `jj undo`. ## Conflicts Conflicts are recorded values inside commits, not a mode your shell is trapped in. A conflicting rebase **finishes anyway**; `jj st` and `jj resolve --list` show what is unresolved. - **`jj resolve`** opens the merge tool (`--tool NAME` to pick one), or edit the markers by hand and save — jj notices on the next command. Nothing to "continue". - **`jj squash`** folds a hand-edited fix down into the conflicted commit. - **`jj undo`** unwinds the whole merge or rebase, because it was one operation. jj's markers are **not** git's `<<<<<<< / ======= / >>>>>>>`. One side is written out in full after `+++++++`; the other is shown as a **diff** after `%%%%%%%`: ```text <<<<<<< conflict 1 of 1 +++++++ lxmrmuxm "nmap: bump fast sweep to --min-rate 5000" (rebase destination) nmap -sC -sV --min-rate 5000 -oA scans/initial 10.10.11.0/24 %%%%%%% diff from: pyuuvvoq "tmux: add ..." (parents of rebased revision) \\\\\\\ to: lvvmtnup (rebased revision) -nmap -sC -sV -oA scans/initial 10.10.11.0/24 +nmap -sC -sV -T4 -oA scans/initial 10.10.11.0/24 >>>>>>> conflict 1 of 1 ends ``` Delete everything from `<<<<<<<` to `>>>>>>>`, type the one line you actually want, save, then `jj squash`. `ui.conflict-marker-style` defaults to `"diff"` in jj 0.44, which is why the second side is a diff rather than both sides dumped whole. Descendants inherit a conflict, so fix it at the source commit and let the stack re-resolve. jj refuses to push conflicted commits, so a half-resolved mess can never reach GitHub. ## Symptom → fix | you see | it means / do this | |---|---| | push prints `Nothing changed.` | no note moved — `jj bookmark set main -r @-`, push again | | `Non-tracking remote bookmark main@origin exists` | run `jj bookmark track main@origin` once, then push | | `Refusing to create new remote bookmark main@origin` | first push of a new bookmark — `jj git push -b main` | | GitHub shows old files, `jj st` clean | committed but never moved the note — same fix as above | | `Won't push commit … since it has no description` | note points at empty `@` — set it to `@-` | | `Refusing to move bookmark backwards or sideways` | typo in `-r`; you rarely want `--allow-backwards` | | `main??` in the log | divergence — rebase onto `main@origin`, or adopt it | | `(conflict)` in the log | edit the markers, then `jj squash` | | `git status`: "not currently on any branch" | normal in a colocated repo — read `jj bookmark list` | | did something dumb | `jj undo`. Truly. | The debug ladder — climb until it makes sense: ```sh jj st # 1. what does jj think just changed? jj bookmark list --all-remotes # 2. where is every sticky note? jj log # 3. what shape is history in? jj op log -n 10 # 4. what did I actually run? jj undo # 5. reverse the last thing I ran ``` ## Revsets and templates Revsets are the query language accepted anywhere `-r` is: | revset | meaning | |---|---| | `@` `@-` `@+` | working copy, parent, child | | `x::y` | x through y · `::x` ancestors · `x::` descendants | | `x..y` | in y but not x (git's two-dot range) | | `a & b`, `~a` | and, not — for **or**, the operator is the pipe character | | `heads(x)` / `roots(x)` | tips / bases of a set | | `trunk()` | the main bookmark, whatever it is called | | `mutable()` / `immutable()` | what may be rewritten, what may not | | `mine()`, `author("x")`, `subject("x")`, `files(glob)` | filters — `subject()` matches the first line | | `empty()`, `merges()`, `conflicts()`, `latest(x, n)` | shapes and slices | `trunk()` is set **per repo** — in this vault it resolves to `main@origin`. `mine`, `wip` and `stack` are **not** defined here, so write the predicates out: `mine()`, `mutable() & mine()`. Templates control output: `-T builtin_log_oneline`, `builtin_log_compact`, `builtin_log_detailed`, or your own — `jj log -T 'change_id.short() ++ " " ++ description' --no-graph` for machine-readable listings. > `git log --author=x --grep=y` is `jj log -r 'author("x") & subject("y")'`. Careful: `description("x")` matches the **whole** message exactly — for a substring it is `description(substring:"x")`. The same operators work on `rebase`, `abandon`, `squash` and `push`, which is why jj has so few flags. ## Repo bootstrap, tags and cleanup - **`jj git init`** / **`jjinit`** — colocate jj with git in place; every git tool keeps working, backing out costs nothing but `rm -rf .jj/`. - **`jj git clone --colocate URL`** / **`jjclone`** — clone with both. - **`jj git remote add origin URL`** · **`jj git remote list`** · **`jj git remote remove origin`** (drops the remote and forgets its bookmarks). **Fresh history, keeping the files** — the `rm -rf .git && git init` recipe, without deleting anything: ```sh jj new 'root()' -m "Initial commit" # empty change parented on the repo root jj restore --from # pull the whole tree in as this commit's content jj bookmark set main -r @ # point main at the new one-commit history jj git remote add origin jj git push --named main=@ ``` The old history is still in the repo (`jj log -r 'all()'`) until you abandon it, so this is reversible. **Tags** are lightweight: `jj tag set v1.0 -r @-`, `jj tag list`, `jj git push --tag v1.0` (`--tag 'glob:v*'` for a family), `jj tag delete v1.0` then push the tag again to propagate it. For an **annotated or signed** tag, use git inside the colocated repo — `git tag -a v1.0 -m "Release" && git push origin v1.0` — then `jj git import`. **Cleanup:** `jj bookmark rename old new` · `jj bookmark delete feat` (propagates on next push) · `jj bookmark forget feat` (local only) · `jj abandon 'wip & ~@'` (throws away a whole revset; undoable). ## git → jj | git said | jj says | what changed | |---|---|---| | `git add` | — | gone; jj snapshots `@` automatically | | `git commit` | `jj commit -m "…"` | same idea, and opens a fresh `@` on top | | `git commit --amend` | `jj squash` | `jj describe` for the message alone | | `git add -p` | `jj squash -i` | choose hunks | | `git commit --fixup` + autosquash | `jj absorb` | no naming anything | | branch | bookmark | renamed, and it never auto-moves | | `git checkout X` | `jj new X` | start a fresh change on top of X | | detached HEAD | — | does not exist; `@` is a commit you are editing | | `git stash` | — | not needed; `@` holds everything, `jj new` parks it | | `git push` | `jj bookmark set main -r @-` then `jj git push` | push sends **bookmarks**, so you move the note first | | `git push -u origin HEAD` | `jj git push --change @` | or `-b NAME` | | `git push origin --delete X` | `jj bookmark delete X` then `jj git push --deleted` | two halves, on purpose | | `git pull` | `jj git fetch`, look, `jj rebase -o main@origin` | split in two on purpose | | `git log` | `jj log` | the graph, with `@` marked | | `git blame` | `jj file annotate ` | | | `git reflog` + `reset --hard` | `jj undo` | one word, undoes any operation | | `git merge --abort` | `jj undo` | still works **after** the merge succeeded | | `git rebase --continue/--abort` | — | neither exists; the rebase already finished | ## Immutability and signing - `trunk()` and its ancestors are **immutable** by default: jj refuses to rewrite them. `--ignore-immutable` overrides, deliberately. - Signing is on (`signing.behavior = "own"`, backend `gpg`, key `BFB092454FAFECB4`) to match `commit.gpgsign = true` in git. Commits you author are signed as they are written. - **`jj sign -r X`** / **`jj unsign -r X`** — add or drop a signature after the fact. - **`jj log -T 'signature.status()'`** — see what is signed. For a throwaway repo, `--config signing.behavior=drop`. ## Aliases on this machine Shell (`~/.dotfiles/config/jj.zsh`, run **`jjhelp`** for the card): | alias | command | |---|---| | `j` `js` `jl` `jll` `jd` `jsh` | jj · status · log · detailed log · diff · show | | `jn` `je` `jdm` `jsq` `jsp` `jr` `jab` | new · edit · describe -m · squash · split · rebase · abandon | | `jb` `jbc` `jbm` | bookmark list / create / move | | `jf` `jpush` `jpushc` | fetch all remotes · push · push --change @ | | `jcm` `jcmp` | commit with date + hostname · commit and push `@-` | | `jop` `jundo` `jrestore` | op log · undo · op restore | | `jjinit` `jjclone` | always `--colocate` | jj ships four built-in aliases that always work: **`jj st`**, **`jj b`**, **`jj ci`**, **`jj desc`**. There are **no** `jj l`, `jj ll`, `jj tug`, `jj oops` or `jj sync` on this machine. `~/.config/jj/config.toml` is short — it sets only `user.name` / `user.email`, `signing.backend = "gpg"` with key `BFB092454FAFECB4`, `signing.behavior = "own"`, and `snapshot.max-new-file-size = "10MiB"` (a bigger new file is **not** auto-snapshotted). Everything else is a jj 0.44 default: `git.colocate = true`, `ui.conflict-marker-style = "diff"`, `git.track-default-bookmark-on-clone = true`. Wrappers in `~/.dotfiles/bin`: **`jj-commit`** (`[--push] [--dry-run] MSG`), **`git-commit`** (`[--add] [--push] MSG`), **`commitdate`**, **`commithost`**, **`datestamp`**. ## Getting in cheaply Run `jj git init` in a repo you already have. Colocation means every git command you know keeps working on the same repo, `jj log` and `git log` show the same commits, and walking away costs nothing but deleting `.jj/`.