just playing with tangled
at gvimdiff 307 lines 12 kB view raw view rendered
1# Git command table 2 3Note that all `jj` commands can be run on any commit (not just the working-copy 4commit), but that's left out of the table to keep it simple. For example, 5`jj squash -r <revision>` will move the diff from that revision into its 6parent. 7 8<table> 9 <thead> 10 <tr> 11 <th>Use case</th> 12 <th>Git command</th> 13 <th>Jujutsu command</th> 14 </tr> 15 </thead> 16 <tbody> 17 <tr> 18 <td>Create a new repo</td> 19 <td><code>git init</code></td> 20 <td><code>jj git init [--colocate]</code></td> 21 </tr> 22 <tr> 23 <td>Clone an existing repo</td> 24 <td><code>git clone &lt;source&gt; &lt;destination&gt; [--origin &lt;remote name&gt;]</code></td> 25 <td><code>jj git clone &lt;source&gt; &lt;destination&gt; [--remote &lt;remote name&gt;]</code> (there is no support 26 for cloning non-Git repos yet)</td> 27 </tr> 28 <tr> 29 <!-- TODO: Mention that you might need to do a `jj bookmark track branch@remote` 30 -- to see the bookmark in `jj log` 31 --> 32 <td>Update the local repo with all bookmarks/branches from a remote</td> 33 <td><code>git fetch [&lt;remote&gt;]</code></td> 34 <td><code>jj git fetch [--remote &lt;remote&gt;]</code> (there is no 35 support for fetching into non-Git repos yet)</td> 36 </tr> 37 <tr> 38 <!-- TODO: This only affects tracked branches now --> 39 <td>Update a remote repo with all bookmarks/branches from the local repo</td> 40 <td><code>git push --all [&lt;remote&gt;]</code></td> 41 <td><code>jj git push --all [--remote &lt;remote&gt;]</code> (there is no 42 support for pushing from non-Git repos yet)</td> 43 </tr> 44 <tr> 45 <td>Update a remote repo with a single bookmark from the local repo</td> 46 <td><code>git push &lt;remote&gt; &lt;bookmark name&gt;</code></td> 47 <td><code>jj git push --bookmark &lt;bookmark name&gt; 48 [--remote &lt;remote&gt;]</code> (there is no support for 49 pushing from non-Git repos yet)</td> 50 </tr> 51 <tr> 52 <td>Add a remote target to the repo</td> 53 <td><code>git remote add &lt;remote&gt; &lt;url&gt;</code></td> 54 <td><code>jj git remote add &lt;remote&gt; &lt;url&gt;</code></td> 55 </tr> 56 <tr> 57 <td>Show summary of current work and repo status</td> 58 <td><code>git status</code></td> 59 <td><code>jj st</code></td> 60 </tr> 61 <tr> 62 <td>Show diff of the current change</td> 63 <td><code>git diff HEAD</code></td> 64 <td><code>jj diff</code></td> 65 </tr> 66 <tr> 67 <td>Show diff of another change</td> 68 <td><code>git diff &lt;revision&gt;^ &lt;revision&gt;</code></td> 69 <td><code>jj diff -r &lt;revision&gt;</code></td> 70 </tr> 71 <tr> 72 <td>Show diff from another change to the current change</td> 73 <td><code>git diff &lt;revision&gt;</code></td> 74 <td><code>jj diff --from &lt;revision&gt;</code></td> 75 </tr> 76 <tr> 77 <td>Show diff from change A to change B</td> 78 <td><code>git diff A B</code></td> 79 <td><code>jj diff --from A --to B</code></td> 80 </tr> 81 <tr> 82 <td>Show all the changes in A..B</td> 83 <td><code>git diff A...B</code></td> 84 <td><code>jj diff -r A..B</code></td> 85 </tr> 86 <tr> 87 <td>Show description and diff of a change</td> 88 <td><code>git show &lt;revision&gt;</code></td> 89 <td><code>jj show &lt;revision&gt;</code></td> 90 </tr> 91 <tr> 92 <td>Add a file to the current change</td> 93 <td><code>touch filename; git add filename</code></td> 94 <td><code>touch filename</code></td> 95 </tr> 96 <tr> 97 <td>Remove a file from the current change</td> 98 <td><code>git rm filename</code></td> 99 <td><code>rm filename</code></td> 100 </tr> 101 <tr> 102 <td>Modify a file in the current change</td> 103 <td><code>echo stuff >> filename</code></td> 104 <td><code>echo stuff >> filename</code></td> 105 </tr> 106 <tr> 107 <td>Finish work on the current change and start a new change</td> 108 <td><code>git commit -a</code></td> 109 <td><code>jj commit</code></td> 110 </tr> 111 <tr> 112 <td>See log of ancestors of the current commit</td> 113 <td><code>git log --oneline --graph --decorate</code></td> 114 <td><code>jj log -r ::@</code></td> 115 </tr> 116 <tr> 117 <td>See log of all reachable commits</td> 118 <td><code>git log --oneline --graph --decorate --branches</code></td> 119 <td><code>jj log -r 'all()'</code> or <code>jj log -r ::</code></td> 120 </tr> 121 <tr> 122 <td>Show log of commits not on the main branch</td> 123 <td>(TODO)</td> 124 <td><code>jj log</code></td> 125 </tr> 126 <tr> 127 <td>List versioned files in the working copy</td> 128 <td><code>git ls-files --cached</code></td> 129 <td><code>jj file list</code></td> 130 </tr> 131 <tr> 132 <td>Search among files versioned in the repository</td> 133 <td><code>git grep foo</code></td> 134 <td><code>grep foo $(jj file list)</code>, or <code>rg --no-require-git foo</code></td> 135 </tr> 136 <tr> 137 <td>Abandon the current change and start a new change</td> 138 <td><code>git reset --hard</code> (cannot be undone)</td> 139 <td><code>jj abandon</code></td> 140 </tr> 141 <tr> 142 <td>Make the current change empty</td> 143 <td><code>git reset --hard</code> (same as abandoning a change since Git 144 has no concept of a "change")</td> 145 <td><code>jj restore</code></td> 146 </tr> 147 <tr> 148 <td>Abandon the parent of the working copy, but keep its diff in the working copy</td> 149 <td><code>git reset --soft HEAD~</code></td> 150 <td><code>jj squash --from @-</code></td> 151 </tr> 152 <tr> 153 <td>Discard working copy changes in some files</td> 154 <td><code>git restore &lt;paths&gt;...</code> or <code>git checkout HEAD -- &lt;paths&gt;...</code></td> 155 <td><code>jj restore &lt;paths&gt;...</code></td> 156 </tr> 157 <tr> 158 <td>Edit description (commit message) of the current change</td> 159 <td>Not supported</td> 160 <td><code>jj describe</code></td> 161 </tr> 162 <tr> 163 <td>Edit description (commit message) of the previous change</td> 164 <td><code>git commit --amend --only</code></td> 165 <td><code>jj describe @-</code></td> 166 </tr> 167 <tr> 168 <td>Temporarily put away the current change</td> 169 <td><code>git stash</code></td> 170 <td><code>jj new @-</code> (the old working-copy commit remains as a sibling commit)<br /> 171 (the old working-copy commit X can be restored with <code>jj edit X</code>)</td> 172 </tr> 173 <tr> 174 <td>Start working on a new change based on the &lt;main&gt; bookmark/branch</td> 175 <td><code>git switch -c topic main</code> or 176 <code>git checkout -b topic main</code> (may need to stash or commit 177 first)</td> 178 <td><code>jj new main</code></td> 179 </tr> 180 <tr> 181 <td>Merge branch A into the current change</td> 182 <td><code>git merge A</code></td> 183 <td><code>jj new @ A</code></td> 184 </tr> 185 <tr> 186 <td>Move bookmark/branch A onto bookmark/branch B</td> 187 <td><code>git rebase B A</code> 188 (may need to rebase other descendant branches separately)</td> 189 <td><code>jj rebase -b A -d B</code></td> 190 </tr> 191 <tr> 192 <td>Move change A and its descendants onto change B</td> 193 <td><code>git rebase --onto B A^ &lt;some descendant bookmark&gt;</code> 194 (may need to rebase other descendant bookmarks separately)</td> 195 <td><code>jj rebase -s A -d B</code></td> 196 </tr> 197 <tr> 198 <td>Reorder changes from A-B-C-D to A-C-B-D</td> 199 <td><code>git rebase -i A</code></td> 200 <td><code>jj rebase -r C --before B</code></td> 201 </tr> 202 <tr> 203 <td>Move the diff in the current change into the parent change</td> 204 <td><code>git commit --amend -a</code></td> 205 <td><code>jj squash</code></td> 206 </tr> 207 <tr> 208 <td>Interactively move part of the diff in the current change into the 209 parent change</td> 210 <td><code>git add -p; git commit --amend</code></td> 211 <td><code>jj squash -i</code></td> 212 </tr> 213 <tr> 214 <td>Move the diff in the working copy into an ancestor</td> 215 <td><code>git commit --fixup=X; git rebase -i --autosquash X^</code></td> 216 <td><code>jj squash --into X</code></td> 217 </tr> 218 <tr> 219 <td>Interactively move part of the diff in an arbitrary change to another 220 arbitrary change</td> 221 <td>Not supported</td> 222 <td><code>jj squash -i --from X --into Y</code></td> 223 </tr> 224 <tr> 225 <td>Interactively split the changes in the working copy in two</td> 226 <td><code>git commit -p</code></td> 227 <td><code>jj split</code></td> 228 </tr> 229 <tr> 230 <td>Interactively split an arbitrary change in two</td> 231 <td>Not supported (can be emulated with the "edit" action in 232 <code>git rebase -i</code>)</td> 233 <td><code>jj split -r &lt;revision&gt;</code></td> 234 </tr> 235 <tr> 236 <td>Interactively edit the diff in a given change</td> 237 <td>Not supported (can be emulated with the "edit" action in 238 <code>git rebase -i</code>)</td> 239 <td><code>jj diffedit -r &lt;revision&gt;</code></td> 240 </tr> 241 <tr> 242 <td>Resolve conflicts and continue interrupted operation</td> 243 <td><code>echo resolved > filename; git add filename; git 244 rebase/merge/cherry-pick --continue</code></td> 245 <td><code>echo resolved > filename; jj squash</code> (operations 246 don't get interrupted, so no need to continue)</td> 247 </tr> 248 <tr> 249 <td>Create a copy of a commit on top of another commit</td> 250 <td><code>git co &lt;destination&gt;; git cherry-pick &lt;source&gt;</code></td> 251 <td><code>jj duplicate &lt;source&gt; -d &lt;destination&gt;</code></td> 252 </tr> 253 <tr> 254 <td>Find the root of the working copy (or check if in a repo)</td> 255 <td><code>git rev-parse --show-toplevel</code></td> 256 <td><code>jj workspace root</code></td> 257 </tr> 258 <tr> 259 <td>List bookmarks/branches</td> 260 <td><code>git branch</code></td> 261 <td><code>jj bookmark list</code> or <code>jj b l</code> for short</td> 262 </tr> 263 <tr> 264 <td>Create a bookmark/branch</td> 265 <td><code>git branch &lt;name&gt; &lt;revision&gt;</code></td> 266 <td><code>jj bookmark create &lt;name&gt; -r &lt;revision&gt;</code></td> 267 </tr> 268 <tr> 269 <td>Move a bookmark/branch forward</td> 270 <td><code>git branch -f &lt;name&gt; &lt;revision&gt;</code></td> 271 <td><code>jj bookmark move &lt;name&gt; --to &lt;revision&gt;</code> 272 or <code>jj b m &lt;name&gt; --to &lt;revision&gt;</code> for short</td> 273 </tr> 274 <tr> 275 <td>Move a bookmark/branch backward or sideways</td> 276 <td><code>git branch -f &lt;name&gt; &lt;revision&gt;</code></td> 277 <td><code>jj bookmark move &lt;name&gt; --to &lt;revision&gt; --allow-backwards</code></td> 278 </tr> 279 <tr> 280 <td>Delete a bookmark/branch</td> 281 <td><code>git branch --delete &lt;name&gt;</code></td> 282 <td><code>jj bookmark delete &lt;name&gt; </code></td> 283 </tr> 284 <tr> 285 <td>See log of operations performed on the repo</td> 286 <td>Not supported</td> 287 <td><code>jj op log</code></td> 288 </tr> 289 <tr> 290 <td>Undo an earlier operation</td> 291 <td>Not supported</td> 292 <td><code>jj [op] undo &lt;operation ID&gt;</code> 293 (<code>jj undo</code> is an alias for <code>jj op undo</code>) 294 </td> 295 </tr> 296 <tr> 297 <td>Create a commit that cancels out a previous commit</td> 298 <td><code>git revert &lt;revision&gt;</code></td> 299 <td><code>jj backout -r &lt;revision&gt;</code></td> 300 </tr> 301 <tr> 302 <td>Show what revision and author last modified each line of a file</td> 303 <td><code>git blame &lt;file&gt;</code></td> 304 <td><code>jj file annotate &lt;path&gt;</code></td> 305 </tr> 306 </tbody> 307</table>