| 1 |
- Use case: Create a new repo |
| 2 |
Git command: > |
| 3 |
`git init` |
| 4 |
Jujutsu command: > |
| 5 |
`jj git init [--no-colocate]` |
| 6 |
Notes: |
| 7 |
|
| 8 |
- Use case: Clone an existing repo |
| 9 |
Git command: > |
| 10 |
`git clone <source> <destination> [--origin <remote name>]` |
| 11 |
Jujutsu command: > |
| 12 |
`jj git clone <source> <destination> [--remote <remote name>]` |
| 13 |
Notes: There is no support for cloning non-Git repos yet. |
| 14 |
|
| 15 |
# TODO: Mention that you might need to do a `jj bookmark track branch` to see |
| 16 |
# the bookmark in `jj log`. |
| 17 |
- Use case: Update the local repo with all bookmarks/branches from a remote |
| 18 |
Git command: > |
| 19 |
`git fetch [<remote>]` |
| 20 |
Jujutsu command: > |
| 21 |
`jj git fetch [--remote <remote>]` |
| 22 |
Notes: There is no support for fetching into non-Git repos yet. |
| 23 |
|
| 24 |
# TODO: This only affects tracked branches now. |
| 25 |
- Use case: Update a remote repo with all bookmarks/branches from the local repo |
| 26 |
Git command: > |
| 27 |
`git push --all [<remote>]` |
| 28 |
Jujutsu command: > |
| 29 |
`jj git push --all [--remote <remote>]` |
| 30 |
Notes: There is no support for pushing from non-Git repos yet. |
| 31 |
|
| 32 |
- Use case: Update a remote repo with a single bookmark from the local repo |
| 33 |
Git command: > |
| 34 |
`git push <remote> <bookmark name>` |
| 35 |
Jujutsu command: > |
| 36 |
`jj git push --bookmark <bookmark name> [--remote <remote>]` |
| 37 |
Notes: There is no support for pushing from non-Git repos yet. |
| 38 |
|
| 39 |
- Use case: Add a remote target to the repo |
| 40 |
Git command: > |
| 41 |
`git remote add <remote> <url>` |
| 42 |
Jujutsu command: > |
| 43 |
`jj git remote add <remote> <url>` |
| 44 |
Notes: |
| 45 |
|
| 46 |
- Use case: Show summary of current work and repo status |
| 47 |
Git command: > |
| 48 |
`git status` |
| 49 |
Jujutsu command: > |
| 50 |
`jj st` |
| 51 |
Notes: |
| 52 |
|
| 53 |
- Use case: Show diff of the current change |
| 54 |
Git command: > |
| 55 |
`git diff HEAD` |
| 56 |
Jujutsu command: > |
| 57 |
`jj diff` |
| 58 |
Notes: |
| 59 |
|
| 60 |
- Use case: Show diff of another change |
| 61 |
Git command: > |
| 62 |
`git diff <revision>^ <revision>` |
| 63 |
Jujutsu command: > |
| 64 |
`jj diff -r <revision>` |
| 65 |
Notes: |
| 66 |
|
| 67 |
- Use case: Show diff from another change to the current change |
| 68 |
Git command: > |
| 69 |
`git diff <revision>` |
| 70 |
Jujutsu command: > |
| 71 |
`jj diff --from <revision>` |
| 72 |
Notes: |
| 73 |
|
| 74 |
- Use case: Show diff from change A to change B |
| 75 |
Git command: > |
| 76 |
`git diff A B` |
| 77 |
Jujutsu command: > |
| 78 |
`jj diff --from A --to B` |
| 79 |
Notes: |
| 80 |
|
| 81 |
- Use case: Show all the changes in A..B |
| 82 |
Git command: > |
| 83 |
`git diff A...B` |
| 84 |
Jujutsu command: > |
| 85 |
`jj diff -r A..B` |
| 86 |
Notes: |
| 87 |
|
| 88 |
- Use case: Show description and diff of a change |
| 89 |
Git command: > |
| 90 |
`git show <revision>` |
| 91 |
Jujutsu command: > |
| 92 |
`jj show <revision>` |
| 93 |
Notes: |
| 94 |
|
| 95 |
- Use case: Add a file to the current change |
| 96 |
Git command: > |
| 97 |
`touch filename; git add filename` |
| 98 |
Jujutsu command: > |
| 99 |
`touch filename` |
| 100 |
Notes: |
| 101 |
|
| 102 |
- Use case: Remove a file from the current change |
| 103 |
Git command: > |
| 104 |
`git rm filename` |
| 105 |
Jujutsu command: > |
| 106 |
`rm filename` |
| 107 |
Notes: |
| 108 |
|
| 109 |
- Use case: > |
| 110 |
Remove a previously tracked file from the current change, but keep it in the working |
| 111 |
copy |
| 112 |
Git command: > |
| 113 |
`git rm --cached filename` |
| 114 |
Jujutsu command: > |
| 115 |
`jj file untrack filename` |
| 116 |
Notes: > |
| 117 |
File name must match an ignore pattern to remain untracked. See |
| 118 |
[the documentation for working copies](../working-copy/#introduction) for more. |
| 119 |
|
| 120 |
- Use case: Modify a file in the current change |
| 121 |
Git command: > |
| 122 |
`echo stuff >> filename` |
| 123 |
Jujutsu command: > |
| 124 |
`echo stuff >> filename` |
| 125 |
Notes: |
| 126 |
|
| 127 |
- Use case: Finish work on the current change and start a new change |
| 128 |
Git command: > |
| 129 |
`git commit -a` |
| 130 |
Jujutsu command: > |
| 131 |
`jj commit` |
| 132 |
Notes: |
| 133 |
|
| 134 |
- Use case: See compact log graph of ancestors of the current commit |
| 135 |
Git command: > |
| 136 |
`git log --oneline --graph` |
| 137 |
Jujutsu command: > |
| 138 |
`jj log -r ::@` |
| 139 |
Notes: |
| 140 |
|
| 141 |
- Use case: See compact log graph of all reachable commits |
| 142 |
Git command: > |
| 143 |
`git log --oneline --graph --all` |
| 144 |
Jujutsu command: > |
| 145 |
`jj log -r 'all()'` |
| 146 |
or `jj log -r ::` |
| 147 |
Notes: > |
| 148 |
In a Git-backed Jujutsu repository the Git command will also show all commits preserved by Jujutsu, |
| 149 |
including hidden commits. To exclude all commits only preserved by Jujutsu, replace `--all` by `--exclude refs/jj/* --all`. |
| 150 |
This will also exclude the Jujutsu-reachable commits though, if they are not Git-reachable. |
| 151 |
|
| 152 |
- Use case: Show compact log graph of commits not on the main branch |
| 153 |
Git command: > |
| 154 |
`git log --oneline --graph --branches --not upstream/main` |
| 155 |
Jujutsu command: > |
| 156 |
`jj log` |
| 157 |
Notes: |
| 158 |
|
| 159 |
- Use case: > |
| 160 |
Show log of commits that have the string "stuff" in the changed lines, |
| 161 |
also known as the "pickaxe" in Git |
| 162 |
Git command: > |
| 163 |
`git log -G stuff` |
| 164 |
Jujutsu command: > |
| 165 |
`jj log -r 'diff_lines(regex:stuff)'` |
| 166 |
Notes: |
| 167 |
|
| 168 |
- Use case: List versioned files in the working copy |
| 169 |
Git command: > |
| 170 |
`git ls-files --cached` |
| 171 |
Jujutsu command: > |
| 172 |
`jj file list` |
| 173 |
Notes: |
| 174 |
|
| 175 |
- Use case: Search among files versioned in the repository |
| 176 |
Git command: > |
| 177 |
`git grep foo` |
| 178 |
Jujutsu command: > |
| 179 |
`jj file search --pattern=foo` |
| 180 |
or `rg --no-require-git foo` |
| 181 |
Notes: |
| 182 |
|
| 183 |
- Use case: Abandon the current change and start a new change |
| 184 |
Git command: > |
| 185 |
`git reset --hard` |
| 186 |
(cannot be undone) |
| 187 |
Jujutsu command: > |
| 188 |
`jj abandon` |
| 189 |
Notes: |
| 190 |
|
| 191 |
- Use case: Make the current change empty |
| 192 |
Git command: > |
| 193 |
`git reset --hard` |
| 194 |
(same as abandoning a change since Git has no concept of a "change") |
| 195 |
Jujutsu command: > |
| 196 |
`jj restore` |
| 197 |
Notes: |
| 198 |
|
| 199 |
- Use case: Abandon the parent of the working copy, but keep its diff in the working copy |
| 200 |
Git command: > |
| 201 |
`git reset --soft HEAD~` |
| 202 |
Jujutsu command: > |
| 203 |
`jj squash --from @-` |
| 204 |
Notes: |
| 205 |
|
| 206 |
- Use case: Discard working copy changes in some files |
| 207 |
Git command: > |
| 208 |
`git restore <paths>...` |
| 209 |
or `git checkout HEAD -- <paths>...` |
| 210 |
Jujutsu command: > |
| 211 |
`jj restore <paths>...` |
| 212 |
Notes: |
| 213 |
|
| 214 |
- Use case: Edit description (commit message) of the current change |
| 215 |
Git command: Not supported |
| 216 |
Jujutsu command: > |
| 217 |
`jj describe` |
| 218 |
Notes: |
| 219 |
|
| 220 |
- Use case: Edit description (commit message) of the previous change |
| 221 |
Git command: > |
| 222 |
`git commit --amend --only` |
| 223 |
Jujutsu command: > |
| 224 |
`jj describe @-` |
| 225 |
Notes: |
| 226 |
|
| 227 |
- Use case: Edit description (commit message) of any change |
| 228 |
Git command: > |
| 229 |
`git commit --fixup=reword:X; git rebase --autosquash X^` |
| 230 |
Jujutsu command: > |
| 231 |
`jj describe X` |
| 232 |
Notes: |
| 233 |
|
| 234 |
- Use case: Temporarily put away the current change |
| 235 |
Git command: > |
| 236 |
`git stash` |
| 237 |
Jujutsu command: > |
| 238 |
`jj new @-` |
| 239 |
Notes: > |
| 240 |
The old working-copy commit remains as a sibling commit. |
| 241 |
The old working-copy commit X can be restored with `jj edit X`. |
| 242 |
|
| 243 |
- Use case: Start working on a new change based on the <main> bookmark/branch |
| 244 |
Git command: > |
| 245 |
`git switch -c topic main` |
| 246 |
or `git checkout -b topic main` |
| 247 |
(may need to stash or commit first) |
| 248 |
Jujutsu command: > |
| 249 |
`jj new main` |
| 250 |
Notes: |
| 251 |
|
| 252 |
- Use case: Merge branch A into the current change |
| 253 |
Git command: > |
| 254 |
`git merge A` |
| 255 |
Jujutsu command: > |
| 256 |
`jj new @ A` |
| 257 |
Notes: |
| 258 |
|
| 259 |
- Use case: Check out a named revision (or branch) to examine source |
| 260 |
Git command: > |
| 261 |
`git checkout v1.0.1` |
| 262 |
Jujutsu command: > |
| 263 |
`jj new v1.0.1` |
| 264 |
Notes: Creates new empty change on top (see `jj new main`) |
| 265 |
|
| 266 |
- Use case: Move bookmark/branch A onto bookmark/branch B |
| 267 |
Git command: > |
| 268 |
`git rebase B A` |
| 269 |
(may need to rebase other descendant branches separately) |
| 270 |
Jujutsu command: > |
| 271 |
`jj rebase -b A -o B` |
| 272 |
Notes: |
| 273 |
|
| 274 |
- Use case: Move change A and its descendants onto change B |
| 275 |
Git command: > |
| 276 |
`git rebase --onto B A^ <some descendant bookmark>` |
| 277 |
(may need to rebase other descendant bookmarks separately) |
| 278 |
Jujutsu command: > |
| 279 |
`jj rebase -s A -o B` |
| 280 |
Notes: |
| 281 |
|
| 282 |
- Use case: Reorder changes from A-B-C-D to A-C-B-D |
| 283 |
Git command: > |
| 284 |
`git rebase -i A` |
| 285 |
Jujutsu command: > |
| 286 |
`jj rebase -r C --before B` |
| 287 |
Notes: |
| 288 |
|
| 289 |
- Use case: Reorder multiple commits at once |
| 290 |
Git command: > |
| 291 |
`git rebase -i` |
| 292 |
Jujutsu command: > |
| 293 |
`jj arrange` |
| 294 |
Notes: |
| 295 |
|
| 296 |
- Use case: Move the diff in the current change into the parent change |
| 297 |
Git command: > |
| 298 |
`git commit --amend -a` |
| 299 |
Jujutsu command: > |
| 300 |
`jj squash` |
| 301 |
Notes: |
| 302 |
|
| 303 |
- Use case: Interactively move part of the diff in the current change into the parent change |
| 304 |
Git command: > |
| 305 |
`git add -p; git commit --amend` |
| 306 |
Jujutsu command: > |
| 307 |
`jj squash -i` |
| 308 |
Notes: |
| 309 |
|
| 310 |
- Use case: Move the diff in the working copy into an ancestor |
| 311 |
Git command: > |
| 312 |
`git commit --fixup=X; git rebase --autosquash X^` |
| 313 |
Jujutsu command: > |
| 314 |
`jj squash --into X` |
| 315 |
Notes: |
| 316 |
|
| 317 |
- Use case: |
| 318 |
Interactively move part of the diff in an arbitrary change to another arbitrary |
| 319 |
change |
| 320 |
Git command: Not supported |
| 321 |
Jujutsu command: > |
| 322 |
`jj squash -i --from X --into Y` |
| 323 |
Notes: |
| 324 |
|
| 325 |
- Use case: Interactively split the changes in the working copy in two |
| 326 |
Git command: > |
| 327 |
`git commit -p` |
| 328 |
Jujutsu command: > |
| 329 |
`jj split` |
| 330 |
Notes: |
| 331 |
|
| 332 |
- Use case: Interactively split an arbitrary change in two |
| 333 |
Git command: > |
| 334 |
Not supported |
| 335 |
(can be emulated with the "edit" action in `git rebase -i`) |
| 336 |
Jujutsu command: > |
| 337 |
`jj split -r <revision>` |
| 338 |
Notes: |
| 339 |
|
| 340 |
- Use case: Interactively edit the diff in a given change |
| 341 |
Git command: > |
| 342 |
Not supported |
| 343 |
(can be emulated with the "edit" action in `git rebase -i`) |
| 344 |
Jujutsu command: > |
| 345 |
`jj diffedit -r <revision>` |
| 346 |
Notes: |
| 347 |
|
| 348 |
- Use case: Resolve conflicts and continue interrupted operation |
| 349 |
Git command: > |
| 350 |
`echo resolved > filename; git add filename; git rebase/merge/cherry-pick |
| 351 |
--continue` |
| 352 |
Jujutsu command: > |
| 353 |
`echo resolved > filename; jj squash` |
| 354 |
Notes: Operations don't get interrupted, so no need to continue. |
| 355 |
|
| 356 |
- Use case: Create a copy of a commit on top of another commit |
| 357 |
Git command: > |
| 358 |
`git co <destination>; git cherry-pick <source>` |
| 359 |
Jujutsu command: > |
| 360 |
`jj duplicate <source> -o <destination>` |
| 361 |
Notes: |
| 362 |
|
| 363 |
- Use case: Find the root of the working copy (or check if in a repo) |
| 364 |
Git command: > |
| 365 |
`git rev-parse --show-toplevel` |
| 366 |
Jujutsu command: > |
| 367 |
`jj workspace root` |
| 368 |
Notes: |
| 369 |
|
| 370 |
- Use case: List bookmarks/branches |
| 371 |
Git command: > |
| 372 |
`git branch` |
| 373 |
Jujutsu command: > |
| 374 |
`jj bookmark list` |
| 375 |
or `jj b l` for short |
| 376 |
Notes: |
| 377 |
|
| 378 |
- Use case: Create a bookmark/branch |
| 379 |
Git command: > |
| 380 |
`git branch <name> <revision>` |
| 381 |
Jujutsu command: > |
| 382 |
`jj bookmark create <name> -r <revision>` |
| 383 |
Notes: |
| 384 |
|
| 385 |
- Use case: Move a bookmark/branch forward |
| 386 |
Git command: > |
| 387 |
`git branch -f <name> <revision>` |
| 388 |
Jujutsu command: > |
| 389 |
`jj bookmark move <name> --to <revision>` |
| 390 |
or `jj b m <name> -t <revision>` for short |
| 391 |
Notes: |
| 392 |
|
| 393 |
- Use case: Move a bookmark/branch backward or sideways |
| 394 |
Git command: > |
| 395 |
`git branch -f <name> <revision>` |
| 396 |
Jujutsu command: > |
| 397 |
`jj bookmark move <name> --to <revision> --allow-backwards` |
| 398 |
Notes: |
| 399 |
|
| 400 |
- Use case: Delete a bookmark/branch |
| 401 |
Git command: > |
| 402 |
`git branch --delete <name>` |
| 403 |
Jujutsu command: > |
| 404 |
`jj bookmark delete <name>` |
| 405 |
Notes: |
| 406 |
|
| 407 |
- Use case: List tags |
| 408 |
Git command: > |
| 409 |
`git tag -l` |
| 410 |
Jujutsu command: > |
| 411 |
`jj tag list` |
| 412 |
Notes: |
| 413 |
|
| 414 |
- Use case: Create a tag |
| 415 |
Git command: > |
| 416 |
`git tag <name> <revision>` |
| 417 |
Jujutsu command: > |
| 418 |
`jj tag set <name> -r <revision>` |
| 419 |
Notes: |
| 420 |
|
| 421 |
- Use case: Delete a tag |
| 422 |
Git command: > |
| 423 |
`git tag -d <name>` |
| 424 |
Jujutsu command: > |
| 425 |
`jj tag delete <name>` |
| 426 |
Notes: |
| 427 |
|
| 428 |
- Use case: List tags that contain a revision (targets are descendants of the revision) |
| 429 |
Git command: > |
| 430 |
`git tag --contains <revision>` |
| 431 |
Jujutsu command: > |
| 432 |
`jj tag list -r '<revision>::'` |
| 433 |
Notes: > |
| 434 |
Uses jj's revset language. The `::` postfix operator selects all |
| 435 |
descendants of the given revision. |
| 436 |
|
| 437 |
- Use case: List tags merged into a revision (targets are ancestors of the revision) |
| 438 |
Git command: > |
| 439 |
`git tag --merged <revision>` |
| 440 |
Jujutsu command: > |
| 441 |
`jj tag list -r '::<revision>'` |
| 442 |
Notes: > |
| 443 |
Uses jj's revset language. The `::` prefix operator selects all |
| 444 |
ancestors of the given revision. |
| 445 |
|
| 446 |
- Use case: See log of operations performed on the repo |
| 447 |
Git command: Not supported |
| 448 |
Jujutsu command: > |
| 449 |
`jj op log` |
| 450 |
Notes: |
| 451 |
|
| 452 |
- Use case: Undo the last operation |
| 453 |
Git command: Not supported |
| 454 |
Jujutsu command: > |
| 455 |
`jj undo` |
| 456 |
Notes: > |
| 457 |
There is also a matching `jj redo` command to redo the most recently undone |
| 458 |
operation. |
| 459 |
|
| 460 |
- Use case: Revert an earlier operation |
| 461 |
Git command: Not supported |
| 462 |
Jujutsu command: > |
| 463 |
`jj op revert` |
| 464 |
Notes: |
| 465 |
|
| 466 |
- Use case: Create a commit that cancels out a previous commit |
| 467 |
Git command: > |
| 468 |
`git revert <revision>` |
| 469 |
Jujutsu command: > |
| 470 |
`jj revert -r <revision> -B @` |
| 471 |
Notes: |
| 472 |
|
| 473 |
- Use case: Show what revision and author last modified each line of a file |
| 474 |
Git command: > |
| 475 |
`git blame <file>` |
| 476 |
Jujutsu command: > |
| 477 |
`jj file annotate <path>` |
| 478 |
Notes: |