From de5aa1ac6c9f4bc2227b54d27f4388e453faa23f Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 29 Aug 2021 23:25:53 -0700 Subject: [PATCH] docs: add a table of git/jj command equivalences --- docs/git-comparison.md | 165 +++++++++++++++++++++++++++++++++++++++++ src/commands.rs | 8 ++ 2 files changed, 173 insertions(+) create mode 100644 docs/git-comparison.md diff --git a/docs/git-comparison.md b/docs/git-comparison.md new file mode 100644 index 000000000..fb77c3e4e --- /dev/null +++ b/docs/git-comparison.md @@ -0,0 +1,165 @@ +# Comparison with Git + +TODO: Describe the differences compared to Git here + +## 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 caseJujutsu commandGit command
Create a new repojj init --git (without --git, you get a + native Jujutsu repo, which is slow and whose format will change)git init
Clone an existing repojj git clone <source> <destination> (there is no support + for cloning non-Git repos yet)git clone <source> <destination>
Show summary of current work and repo statusjj stgit st
Show diff of the current changejj diffgit diff HEAD
Show diff of another changejj diff -r <revision>git diff <revision>^ <revision>
Add a file to the current changetouch filenametouch filename; git add filename
Remove a file from the current changerm filenamegit rm filename
Modify a file in the current changeecho stuff >> filenameecho stuff >> filename; git add filename
Finish work on the current change and start a new changejj closegit commit -a
See log of commitsjj loggit log --oneline --graph --decorate
Abandon the current change and start a new changejj prunegit reset --hard (cannot be undone)
Make the current change emptyjj restoregit reset --hard (same as abandoning a change since Git + has no concept of a "change")
Edit description (commit message) of the current changejj describeNot supported
Edit description (commit message) of the previous changejj describe :@git commit --amend (first make sure that nothing is + staged)
Temporarily put away the current changeNot neededgit stash
Start working on a new change based on the <main> branchjj co maingit checkout -b topic main (may need to stash or commit + first)
Move branch A onto branch BNot supported yet (can be emulated with + jj rebase -s)git rebase B A + (may need to rebase other descendant branches separately)
Move change A and its descendants onto change Bjj rebase -s A -d Bgit rebase --onto B A^ <some descendant branch> + (may need to rebase other descendant branches separately)
Reorder changes from A-B-C-D to A-C-B-Djj rebase -r C -d A; rebase -s B -d C (pass change ids, + not commit ids, to not have to look up commit id of rewritten C)git rebase -i A
Move the diff in the current change into the parent changejj squashgit commit --amend -a
Interactively move part of the diff in the current change into the + parent changejj squash -igit add -p; git commit --amend
Interactively split a change in twojj split -r <revision>Not supported (can be emulated with the "edit" action in + git rebase -i)
Interactively edit the diff in a given changejj edit -r <revision>Not supported (can be emulated with the "edit" action in + git rebase -i)
Resolve conflicts and continue interrupted operationecho resolved > filename; jj squash (operations don't + get interrupted, so no need to continue)echo resolved > filename; git add filename; git + rebase/merge/cherry-pick --continue
See log of operations performed on the repojj op logNot supported
Undo an earlier operationjj op undo -o <operation id>Not supported
diff --git a/src/commands.rs b/src/commands.rs index bee7c7027..3c1a44313 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1213,6 +1213,14 @@ See `jj concepts branches` for information about branches.", ); let git_command = SubCommand::with_name("git") .about("Commands for working with the underlying Git repo") + .long_about( + "Commands for working with the underlying Git repo. + +For a comparison with Git, including \ + a table of commands, see +https://github.com/martinvonz/jj/blob/main/docs/git-comparison.md.\ + ", + ) .setting(clap::AppSettings::SubcommandRequiredElseHelp) .subcommand( SubCommand::with_name("fetch")