diff --git a/cli/src/commands/git/mod.rs b/cli/src/commands/git/mod.rs index 38069aca2..417e3f6da 100644 --- a/cli/src/commands/git/mod.rs +++ b/cli/src/commands/git/mod.rs @@ -61,7 +61,7 @@ use crate::ui::Ui; /// https://jj-vcs.github.io/jj/latest/git-comparison/. /// /// [table of commands]: -/// https://jj-vcs.github.io/jj/latest/git-comparison/#command-equivalence-table +/// https://jj-vcs.github.io/jj/latest/git-command-table #[derive(Subcommand, Clone, Debug)] pub enum GitCommand { Clone(GitCloneArgs), diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index 67d4afba5..fe1516138 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -1082,7 +1082,7 @@ See this [comparison], including a [table of commands]. [comparison]: https://jj-vcs.github.io/jj/latest/git-comparison/. -[table of commands]: https://jj-vcs.github.io/jj/latest/git-comparison/#command-equivalence-table +[table of commands]: https://jj-vcs.github.io/jj/latest/git-command-table **Usage:** `jj git ` diff --git a/docs/git-command-table.md b/docs/git-command-table.md new file mode 100644 index 000000000..1f0ba774e --- /dev/null +++ b/docs/git-command-table.md @@ -0,0 +1,303 @@ +# 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 ` will move the diff from that revision into its +parent. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Use caseGit commandJujutsu command
Create a new repogit initjj git init [--colocate]
Clone an existing repogit 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 remotegit 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 repogit 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 repogit 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 repogit remote add <remote> <url>jj git remote add <remote> <url>
Show summary of current work and repo statusgit statusjj st
Show diff of the current changegit diff HEADjj diff
Show diff of another changegit diff <revision>^ <revision>jj diff -r <revision>
Show diff from another change to the current changegit diff <revision>jj diff --from <revision>
Show diff from change A to change Bgit diff A Bjj diff --from A --to B
Show description and diff of a changegit show <revision>jj show <revision>
Add a file to the current changetouch filename; git add filenametouch filename
Remove a file from the current changegit rm filenamerm filename
Modify a file in the current changeecho stuff >> filenameecho stuff >> filename
Finish work on the current change and start a new changegit commit -ajj commit
See log of ancestors of the current commitgit log --oneline --graph --decoratejj log -r ::@
See log of all reachable commitsgit log --oneline --graph --decorate --branchesjj log -r 'all()' or jj log -r ::
Show log of commits not on the main bookmark(TODO)jj log
List versioned files in the working copygit ls-files --cachedjj file list
Search among files versioned in the repositorygit grep foogrep foo $(jj file list), or rg --no-require-git foo
Abandon the current change and start a new changegit reset --hard (cannot be undone)jj abandon
Make the current change emptygit 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 copygit reset --soft HEAD~jj squash --from @-
Discard working copy changes in some filesgit restore <paths>... or git checkout HEAD -- <paths>...jj restore <paths>...
Edit description (commit message) of the current changeNot supportedjj describe
Edit description (commit message) of the previous changegit commit --amend --onlyjj describe @-
Temporarily put away the current changegit stashjj 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 <main> bookmark/branchgit 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 changegit merge Ajj new @ A
Move bookmark/branch A onto bookmark/branch Bgit 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 Bgit 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-Dgit rebase -i Ajj rebase -r C --before B
Move the diff in the current change into the parent changegit commit --amend -ajj squash
Interactively move part of the diff in the current change into the + parent changegit add -p; git commit --amendjj squash -i
Move the diff in the working copy into an ancestorgit 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 changeNot supportedjj squash -i --from X --into Y
Interactively split the changes in the working copy in twogit commit -pjj split
Interactively split an arbitrary change in twoNot supported (can be emulated with the "edit" action in + git rebase -i)jj split -r <revision>
Interactively edit the diff in a given changeNot supported (can be emulated with the "edit" action in + git rebase -i)jj diffedit -r <revision>
Resolve conflicts and continue interrupted operationecho resolved > filename; git add filename; git + rebase/merge/cherry-pick --continueecho resolved > filename; jj squash (operations + don't get interrupted, so no need to continue)
Create a copy of a commit on top of another commitgit 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-topleveljj workspace root
List bookmarks/branchesgit branchjj bookmark list or jj b l for short
Create a bookmark/branchgit branch <name> <revision>jj bookmark create <name> -r <revision>
Move a bookmark/branch forwardgit 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 sidewaysgit branch -f <name> <revision>jj bookmark move <name> --to <revision> --allow-backwards
Delete a bookmark/branchgit branch --delete <name>jj bookmark delete <name>
See log of operations performed on the repoNot supportedjj op log
Undo an earlier operationNot supportedjj [op] undo <operation ID> + (jj undo is an alias for jj op undo) +
Create a commit that cancels out a previous commitgit revert <revision>jj backout -r <revision>
Show what revision and author last modified each line of a filegit blame <file>jj file annotate <path>
diff --git a/docs/git-comparison.md b/docs/git-comparison.md index debc5da00..d490c20e1 100644 --- a/docs/git-comparison.md +++ b/docs/git-comparison.md @@ -4,15 +4,15 @@ This document attempts to describe how Jujutsu is different from Git. See [the Git-compatibility doc](git-compatibility.md) for information about how -the `jj` command interoperates with Git repos. +the `jj` command interoperates with Git repos. See +[the Git command table](git-command-table.md) for a table of similar commands. ## Overview Here is a list of conceptual differences between Jujutsu and Git, along with links to more details where applicable and available. There's a -[table further down](#command-equivalence-table) explaining how to achieve -various use cases. +[table](git-command-table.md) explaining how to achieve various use cases. * **The working copy is automatically committed.** That results in a simpler and more consistent CLI because the working copy is now treated like any other @@ -82,308 +82,3 @@ changes into the parent commit, which you might normally use `git add -p; git commit --amend` for, you can instead use `jj squash -i` to choose which changes to move into the parent commit, or `jj squash ` to move a specific file. - - -## Command equivalence 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 ` will move the diff from that revision into its -parent. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use caseGit commandJujutsu command
Create a new repogit initjj git init [--colocate]
Clone an existing repogit 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 remotegit 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 repogit 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 repogit 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 repogit remote add <remote> <url>jj git remote add <remote> <url>
Show summary of current work and repo statusgit statusjj st
Show diff of the current changegit diff HEADjj diff
Show diff of another changegit diff <revision>^ <revision>jj diff -r <revision>
Show diff from another change to the current changegit diff <revision>jj diff --from <revision>
Show diff from change A to change Bgit diff A Bjj diff --from A --to B
Show description and diff of a changegit show <revision>jj show <revision>
Add a file to the current changetouch filename; git add filenametouch filename
Remove a file from the current changegit rm filenamerm filename
Modify a file in the current changeecho stuff >> filenameecho stuff >> filename
Finish work on the current change and start a new changegit commit -ajj commit
See log of ancestors of the current commitgit log --oneline --graph --decoratejj log -r ::@
See log of all reachable commitsgit log --oneline --graph --decorate --branchesjj log -r 'all()' or jj log -r ::
Show log of commits not on the main bookmark(TODO)jj log
List versioned files in the working copygit ls-files --cachedjj file list
Search among files versioned in the repositorygit grep foogrep foo $(jj file list), or rg --no-require-git foo
Abandon the current change and start a new changegit reset --hard (cannot be undone)jj abandon
Make the current change emptygit 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 copygit reset --soft HEAD~jj squash --from @-
Discard working copy changes in some filesgit restore <paths>... or git checkout HEAD -- <paths>...jj restore <paths>...
Edit description (commit message) of the current changeNot supportedjj describe
Edit description (commit message) of the previous changegit commit --amend --onlyjj describe @-
Temporarily put away the current changegit stashjj 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 <main> bookmark/branchgit 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 changegit merge Ajj new @ A
Move bookmark/branch A onto bookmark/branch Bgit 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 Bgit 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-Dgit rebase -i Ajj rebase -r C --before B
Move the diff in the current change into the parent changegit commit --amend -ajj squash
Interactively move part of the diff in the current change into the - parent changegit add -p; git commit --amendjj squash -i
Move the diff in the working copy into an ancestorgit 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 changeNot supportedjj squash -i --from X --into Y
Interactively split the changes in the working copy in twogit commit -pjj split
Interactively split an arbitrary change in twoNot supported (can be emulated with the "edit" action in - git rebase -i)jj split -r <revision>
Interactively edit the diff in a given changeNot supported (can be emulated with the "edit" action in - git rebase -i)jj diffedit -r <revision>
Resolve conflicts and continue interrupted operationecho resolved > filename; git add filename; git - rebase/merge/cherry-pick --continueecho resolved > filename; jj squash (operations - don't get interrupted, so no need to continue)
Create a copy of a commit on top of another commitgit 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-topleveljj workspace root
List bookmarks/branchesgit branchjj bookmark list or jj b l for short
Create a bookmark/branchgit branch <name> <revision>jj bookmark create <name> -r <revision>
Move a bookmark/branch forwardgit 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 sidewaysgit branch -f <name> <revision>jj bookmark move <name> --to <revision> --allow-backwards
Delete a bookmark/branchgit branch --delete <name>jj bookmark delete <name>
See log of operations performed on the repoNot supportedjj op log
Undo an earlier operationNot supportedjj [op] undo <operation ID> - (jj undo is an alias for jj op undo) -
Create a commit that cancels out a previous commitgit revert <revision>jj backout -r <revision>
Show what revision and author last modified each line of a filegit blame <file>jj file annotate <path>
diff --git a/mkdocs.yml b/mkdocs.yml index 19a30ab9d..7f14f0000 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -120,6 +120,7 @@ nav: - 'Comparisons': - 'Git comparison': 'git-comparison.md' + - 'Git command table': 'git-command-table.md' - 'Git compatibility': 'git-compatibility.md' - 'Sapling': 'sapling-comparison.md' - 'Other related work': 'related-work.md'