Git command table¶
Note that all jj
commands can be run on any commit (not just the working-copy
commit), but that's left out of the table to keep it simple. For example,
jj squash -r <revision>
will move the diff from that revision into its
parent.
Use case | Git command | Jujutsu command | Notes |
---|---|---|---|
Create a new repo | git init |
jj git init [--colocate] |
|
Clone an existing repo | git clone <source> <destination> [--origin <remote name>] |
jj git clone <source> <destination> [--remote <remote name>] |
There is no support for cloning non-Git repos yet. |
Update the local repo with all bookmarks/branches from a remote | git fetch [<remote>] |
jj git fetch [--remote <remote>] |
There is no support for fetching into non-Git repos yet. |
Update a remote repo with all bookmarks/branches from the local repo | git push --all [<remote>] |
jj git push --all [--remote <remote>] |
There is no support for pushing from non-Git repos yet. |
Update a remote repo with a single bookmark from the local repo | git push <remote> <bookmark name> |
jj git push --bookmark <bookmark name> [--remote <remote>] |
There is no support for pushing from non-Git repos yet. |
Add a remote target to the repo | git remote add <remote> <url> |
jj git remote add <remote> <url> |
|
Show summary of current work and repo status | git status |
jj st |
|
Show diff of the current change | git diff HEAD |
jj diff |
|
Show diff of another change | git diff <revision>^ <revision> |
jj diff -r <revision> |
|
Show diff from another change to the current change | git diff <revision> |
jj diff --from <revision> |
|
Show diff from change A to change B | git diff A B |
jj diff --from A --to B |
|
Show all the changes in A..B | git diff A...B |
jj diff -r A..B |
|
Show description and diff of a change | git show <revision> |
jj show <revision> |
|
Add a file to the current change | touch filename; git add filename |
touch filename |
|
Remove a file from the current change | git rm filename |
rm filename |
|
Modify a file in the current change | echo stuff >> filename |
echo stuff >> filename |
|
Finish work on the current change and start a new change | git commit -a |
jj commit |
|
See log of ancestors of the current commit | git log --oneline --graph --decorate |
jj log -r ::@ |
|
See log of all reachable commits | git log --oneline --graph --decorate --branches |
jj log -r 'all()' or jj log -r :: |
|
Show log of commits not on the main branch | (TODO) | jj log |
|
List versioned files in the working copy | git ls-files --cached |
jj file list |
|
Search among files versioned in the repository | git grep foo |
grep foo $(jj file list) or rg --no-require-git foo |
|
Abandon the current change and start a new change | git reset --hard (cannot be undone) |
jj abandon |
|
Make the current change empty | git reset --hard (same as abandoning a change since Git has no concept of a "change") |
jj restore |
|
Abandon the parent of the working copy, but keep its diff in the working copy | git reset --soft HEAD~ |
jj squash --from @- |
|
Discard working copy changes in some files | git restore <paths>... or git checkout HEAD -- <paths>... |
jj restore <paths>... |
|
Edit description (commit message) of the current change | Not supported | jj describe |
|
Edit description (commit message) of the previous change | git commit --amend --only |
jj describe @- |
|
Temporarily put away the current change | git stash |
jj new @- |
The old working-copy commit remains as a sibling commit. The old working-copy commit X can be restored with jj edit X . |
Start working on a new change based on the |
git switch -c topic main or git checkout -b topic main (may need to stash or commit first) |
jj new main |
|
Merge branch A into the current change | git merge A |
jj new @ A |
|
Move bookmark/branch A onto bookmark/branch B | git rebase B A (may need to rebase other descendant branches separately) |
jj rebase -b A -d B |
|
Move change A and its descendants onto change B | git rebase --onto B A^ <some descendant bookmark> (may need to rebase other descendant bookmarks separately) |
jj rebase -s A -d B |
|
Reorder changes from A-B-C-D to A-C-B-D | git rebase -i A |
jj rebase -r C --before B |
|
Move the diff in the current change into the parent change | git commit --amend -a |
jj squash |
|
Interactively move part of the diff in the current change into the parent change | git add -p; git commit --amend |
jj squash -i |
|
Move the diff in the working copy into an ancestor | git commit --fixup=X; git rebase -i --autosquash X^ |
jj squash --into X |
|
Interactively move part of the diff in an arbitrary change to another arbitrary change | Not supported | jj squash -i --from X --into Y |
|
Interactively split the changes in the working copy in two | git commit -p |
jj split |
|
Interactively split an arbitrary change in two | Not supported (can be emulated with the "edit" action in git rebase -i ) |
jj split -r <revision> |
|
Interactively edit the diff in a given change | Not supported (can be emulated with the "edit" action in git rebase -i ) |
jj diffedit -r <revision> |
|
Resolve conflicts and continue interrupted operation | echo resolved > filename; git add filename; git rebase/merge/cherry-pick --continue |
echo resolved > filename; jj squash |
Operations don't get interrupted, so no need to continue. |
Create a copy of a commit on top of another commit | git co <destination>; git cherry-pick <source> |
jj duplicate <source> -d <destination> |
|
Find the root of the working copy (or check if in a repo) | git rev-parse --show-toplevel |
jj workspace root |
|
List bookmarks/branches | git branch |
jj bookmark list or jj b l for short |
|
Create a bookmark/branch | git branch <name> <revision> |
jj bookmark create <name> -r <revision> |
|
Move a bookmark/branch forward | git branch -f <name> <revision> |
jj bookmark move <name> --to <revision> or jj b m <name> --to <revision> for short |
|
Move a bookmark/branch backward or sideways | git branch -f <name> <revision> |
jj bookmark move <name> --to <revision> --allow-backwards |
|
Delete a bookmark/branch | git branch --delete <name> |
jj bookmark delete <name> |
|
See log of operations performed on the repo | Not supported | jj op log |
|
Undo an earlier operation | Not supported | jj [op] undo <operation ID> |
jj undo is an alias for jj op undo . |
Create a commit that cancels out a previous commit | git revert <revision> |
jj backout -r <revision> |
|
Show what revision and author last modified each line of a file | git blame <file> |
jj file annotate <path> |