Git to JJ
git-to-jj.md edited
74 lines 2.3 kB view raw view rendered
1## How to start (without breaking GitHub) 2 3- In an existing Git repo: run this once in the repo root 4`jj git init --colocate` 5(This makes the repo usable by both Git and jj.) 6 7- Or clone a GitHub repo directly with jj: 8`jj git clone https://github.com/owner/repo.git` 9 10- Configure the remote as usual (jj uses Git remotes): 11`jj git remote add origin <url>` 12 13 14- Push: `jj git push --all` or push a single bookmark: `jj git push --bookmark main` 15 16- Pull/update (jj doesn’t have a one-shot pull): 17`jj git fetch` → then rebase your work: `jj rebase -d <bookmark you track, e.g. main>` 18 19## Git ⇄ jj cheat-sheet (most common) 20 21(Left: Git command → Right: jj equivalent) 22 23`git init``jj git init [--colocate]` 24 25`git clone <url>``jj git clone <url>` 26 27`git status``jj st` 28 29`git diff``jj diff` 30 31`git show <rev>``jj show <rev>` 32 33`git log --oneline --graph``jj log -r ::@` (or `jj log`) 34 35`git fetch``jj git fetch` 36 37`git push --all``jj git push --all` 38 39`git push origin <branch>``jj git push --bookmark <name> [--remote origin]` 40 41`git branch (list)``jj bookmark list` 42 43`git branch <name> <rev>``jj bookmark create <name> -r <rev>` 44 45`git branch -f <name> <rev>``jj bookmark move <name> --to <rev>` 46 47`git branch -d <name>``jj bookmark delete <name>` 48 49`git switch -c topic main``jj new main` (start a new change on top of main) 50 51`git merge A``jj new @ A` (create a merge change with A) 52 53`git rebase B A``jj rebase -b A -d B` 54 55`git cherry-pick X``jj duplicate X -d <destination>` 56 57`git commit -a``jj commit` (finish current change, start a new one) 58 59`git commit --amend` → jj squash (or jj describe to edit the message) 60 61`git restore <paths>` / `git checkout -- <paths>``jj restore <paths>` 62 63`git reset --hard` (drop WIP) → `jj abandon` 64 65`git revert <rev>``jj revert -r <rev> -B @` 66 67`git blame <file>``jj file annotate <path>` 68 69## A couple of jj concepts to know 70 71Bookmarks ≈ 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. 72 73 74Working 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.