jj-operation-restore(1)

πŸ’– NAME πŸ’–

Bestie, you've landed on jj-operation-restore(1), straight outta the General Commands Manual section πŸŽ€ β€” and here's the whole vibe in one line: create a new operation that restores the repo to an earlier state ✨


πŸ“œ SYNOPSIS πŸ“œ

jj operation restore [-R|--repository] [--what] [--ignore-working-copy]
[--no-integrate-operation] [--ignore-immutable] [--at-operation]
[--debug] [--color] [--quiet] [--no-pager] [--config] [--config-file]
[-h|--help] <OPERATION>

πŸ¦‹ DESCRIPTION πŸ¦‹

Create a new operation that restores the repo to an earlier state πŸ‘‘

Basically: this takes your repo back to exactly how it looked at the operation you point at, which lowkey means undoing every single operation that came after it. The way it does that? By making a brand new operation. So nothing is erased-erased, you're just writing a fresh operation that says "yeah we're back here now" πŸ’…


πŸ”₯ OPTIONS πŸ”₯

  • --what <WHAT> [default: repo,remote-tracking] β€” which parts of the local state get restored (and yeah, you can repeat this one) πŸ”
⚠️ Heads up bestie: this option is EXPERIMENTAL.

Possible values:

  • repo: the jj repo state, plus local bookmarks πŸ““
  • remote-tracking: the remote-tracking bookmarks. Do not restore these if you wanna push after the undo, okay? πŸ™ˆ
  • -h, --help β€” print help (or, if you want the short lil summary, hit it with -h) ✨
  • <OPERATION> β€” the operation you're restoring to 🎯

Find the one you want with jj op log. And if you wanna peep what the repo looked like at that operation before you commit to the restore, run something like jj --at-op=<operation ID> log first. Look before you leap, queen πŸ‘‘


πŸ‘‘ GLOBAL OPTIONS πŸ‘‘

  • -R, --repository <REPOSITORY> β€” path to the repository you wanna operate on πŸ—‚οΈ

Default behavior? Jujutsu goes searching for the closest .jj/ directory in an ancestor of wherever your current working directory is. It'll find it, she's thorough πŸ’…

  • --ignore-working-copy β€” don't snapshot the working copy, and don't update it either πŸ™…

So normally, Jujutsu snapshots the working copy at the start of every command. And at the end of the command it updates the working copy too, but only if the command modified the working-copy commit (@). If you'd rather not snapshot and just look at a possibly-stale working-copy commit instead, this is your flag. It's giving "great for a command prompt", especially if you've got another process out there committing the working copy πŸ‘€

Also, loading the repo at a specific operation with --at-operation implies --ignore-working-copy. They're a package deal, no cap 🎁

  • --no-integrate-operation β€” run the command like normal but don't integrate any operations 🚫

When you pass this, the operations still get created as usual, they just don't get integrated into the operation log. And the working copy doesn't get updated either. Periodt.

The command will print the resulting operation ID. You can hand that ID to e.g. jj --at-op to inspect the resulting repo state, or pass it to jj op restore to restore the repo to that state. You can also pass the ID to jj op integrate to integrate the operation 🫢

πŸ’€ But fr fr, note that this does not prevent side effects outside the repo. Like, jj git push --no-integrate-operation will still perform the push. The push is happening, bestie.
  • --ignore-immutable β€” allow rewriting immutable commits 😱

By default, Jujutsu prevents rewriting commits in the configured set of immutable commits. This option disables that check and lets you rewrite any commit but the root commit. Root stays untouchable, she's iconic like that 🌳

This option only affects the check. It does not affect the immutable_heads() revset or the immutable template keyword. Just the check, nothing else, iykyk ✨

  • --at-operation <AT_OPERATION> β€” the operation to load the repo at ⏳

By default, Jujutsu loads the repo at the most recent operation, or at the merge of the divergent operations if there are any.

You can use --at-op=<operation ID> to see what the repo looked like at an earlier operation. For example, jj --at-op=<operation ID> st will show you what jj st would have shown you when the given operation had just finished. And --at-op=@ is pretty much the same as the default, except divergent operations will never be merged πŸ™ˆ

Use jj op log to find the operation ID you want. Any unambiguous prefix of the operation ID is enough β€” you don't gotta type the whole thing, queen πŸ’…

When loading the repo at an earlier operation, the working copy gets ignored, exactly as if --ignore-working-copy had been specified.

And yes, it is possible to run mutating commands while loading the repo at an earlier operation. Doing that is equivalent to having run concurrent commands starting at the earlier operation. There's rarely a reason to do that, but it is possible πŸ‘€ (main character energy, slightly chaotic edition)

  • --debug β€” enable debug logging πŸ›
  • --color <WHEN> β€” when to colorize output 🌈

Possible values:

  • always
  • never
  • debug
  • auto
  • --quiet β€” silence non-primary command output 🀫

For example, jj file list will still list files, but it won't tell you if the working copy was snapshotted or if descendants were rebased.

Warnings and errors will still be printed though. Silence isn't total silence, bestie πŸ“’

  • --no-pager β€” disable the pager πŸ“„
  • --config <NAME=VALUE> β€” additional configuration options (and yep, this can be repeated) βš™οΈ

The name should be specified as TOML dotted keys. The value should be specified as a TOML expression. And if the string value isn't enclosed by any TOML constructs (such as array notation), the quotes can be omitted πŸŽ€

  • --config-file <PATH> β€” additional configuration files (you guessed it, this can be repeated too) πŸ“

That's the whole page, bestie πŸ’œ this one lives in the General Commands Manual, with restore sitting pretty on the left of the footer and jj-operation-restore(1) holding it down on the right. Go forth and un-do things responsibly πŸ¦‹βœ¨

πŸ“¦ where this page comes from