Git to JJ
git-to-jj.md edited
74 lines 2.3 kB view raw view code

How to start (without breaking GitHub)#

  • In an existing Git repo: run this once in the repo root jj git init --colocate (This makes the repo usable by both Git and jj.)

  • Or clone a GitHub repo directly with jj: jj git clone https://github.com/owner/repo.git

  • Configure the remote as usual (jj uses Git remotes): jj git remote add origin <url>

  • Push: jj git push --all or push a single bookmark: jj git push --bookmark main

  • Pull/update (jj doesn’t have a one-shot pull): jj git fetch → then rebase your work: jj rebase -d <bookmark you track, e.g. main>

Git ⇄ jj cheat-sheet (most common)#

(Left: Git command → Right: jj equivalent)

git initjj git init [--colocate]

git clone <url>jj git clone <url>

git statusjj st

git diffjj diff

git show <rev>jj show <rev>

git log --oneline --graphjj log -r ::@ (or jj log)

git fetchjj git fetch

git push --alljj git push --all

git push origin <branch>jj git push --bookmark <name> [--remote origin]

git branch (list)jj bookmark list

git branch <name> <rev>jj bookmark create <name> -r <rev>

git branch -f <name> <rev>jj bookmark move <name> --to <rev>

git branch -d <name>jj bookmark delete <name>

git switch -c topic mainjj new main (start a new change on top of main)

git merge Ajj new @ A (create a merge change with A)

git rebase B Ajj rebase -b A -d B

git cherry-pick Xjj duplicate X -d <destination>

git commit -ajj commit (finish current change, start a new one)

git commit --amend → jj squash (or jj describe to edit the message)

git restore <paths> / git checkout -- <paths>jj restore <paths>

git reset --hard (drop WIP) → jj abandon

git revert <rev>jj revert -r <rev> -B @

git blame <file>jj file annotate <path>

A couple of jj concepts to know#

Bookmarks ≈ Branches: jj uses bookmarks that map 1:1 to Git branches when you push/fetch. So jj git push --bookmark foo updates branch foo on GitHub.

Working copy is a real commit: edits update your current change; you “finish” it with jj commit, and tools like jj split, jj squash, and jj rebase make rewriting history much nicer.