docs: convert Git command table from HTML to YAML

The YAML format is much easier to maintain and allows using Markdown instead of having
to escape symbols such as < and >.
This commit is contained in:
Vincent Ging Ho Yim 2025-04-19 20:52:18 +10:00
parent 8e15a2634a
commit e90727b34d
2 changed files with 338 additions and 300 deletions

View File

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

337
docs/git-command-table.yml Normal file
View File

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