From 0ca9d33dcda5d74a84e90f96d09039ff75ec3bef Mon Sep 17 00:00:00 2001 From: "jj-docs[bot]" Date: Mon, 1 Apr 2024 20:01:33 +0000 Subject: [PATCH] Deployed 7b3f8e8 to prerelease with MkDocs 1.5.3 and mike 2.0.0 --- prerelease/cli-reference/index.html | 8 ++++---- prerelease/search/search_index.json | 2 +- prerelease/sitemap.xml.gz | Bin 468 -> 468 bytes 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/prerelease/cli-reference/index.html b/prerelease/cli-reference/index.html index 512db1b519..858b970e54 100644 --- a/prerelease/cli-reference/index.html +++ b/prerelease/cli-reference/index.html @@ -5599,6 +5599,10 @@
Options:--color <WHEN> — When to colorize output (always, never, auto)

  • +

    --quiet — Silence non-primary command output

    +

    Possible values: true, false

    +
  • +
  • --no-pager — Disable the pager

    Possible values: true, false

  • @@ -6679,10 +6683,6 @@
    Options:jj's documentation website!","text":"

    The complete list of the available documentation pages is located in the sidebar on the left of the page. The sidebar may be hidden; if so, you can open it either by widening your browser window or by clicking on the hamburger menu that appears in this situation.

    Additional help is available using the jj help command if you have jj installed.

    You may want to jump to:

    • Documentation for the latest released version of jj.
    • Documentation for the unreleased version of jj. This version of the docs corresponds to the main branch of the jj repo.
    "},{"location":"#some-useful-links","title":"Some useful links","text":"
    • GitHub repo for jj
    • Overview of jj in the repo's README
    • Installation and Setup
    • Tutorial and Birds-Eye View
    • Working with GitHub
    "},{"location":"FAQ/","title":"Frequently asked questions","text":""},{"location":"FAQ/#why-does-my-branch-not-move-to-the-new-commit-after-jj-newcommit","title":"Why does my branch not move to the new commit after jj new/commit?","text":"

    If you're familiar with Git, you might expect the current branch to move forward when you commit. However, Jujutsu does not have a concept of a \"current branch\".

    To move branches, use jj branch set.

    "},{"location":"FAQ/#i-made-a-commit-and-jj-git-push-all-says-nothing-changed-instead-of-pushing-it-what-do-i-do","title":"I made a commit and jj git push --all says \"Nothing changed\" instead of pushing it. What do I do?","text":"

    jj git push --all pushes all branches, not all revisions. You have two options:

    • Using jj git push --change will automatically create a branch and push it.
    • Using jj branch commands to create or move a branch to either the commit you want to push or a descendant on it. Unlike Git, Jujutsu doesn't do this automatically (see previous question).
    "},{"location":"FAQ/#where-is-my-commit-why-is-it-not-visible-in-jj-log","title":"Where is my commit, why is it not visible in jj log?","text":"

    Is your commit visible with jj log -r 'all()'?

    If yes, you should be aware that jj log only shows the revisions matching revsets.log by default. You can change it as described in config to show more revisions.

    If not, the revision may have been abandoned (e.g. because you used jj abandon, or because it's an obsolete version that's been rewritten with jj rebase, jj describe, etc). In that case, jj log -r commit_id should show the revision as \"hidden\". jj new commit_id should make the revision visible again.

    See revsets and templates for further guidance.

    "},{"location":"FAQ/#how-can-i-get-jj-log-to-show-me-what-git-log-would-show-me","title":"How can I get jj log to show me what git log would show me?","text":"

    Use jj log -r ... The .. operator lists all visible commits in the repo, excluding the root (which is never interesting and is shared by all repos).

    "},{"location":"FAQ/#jj-is-said-to-record-the-working-copy-after-jj-log-and-every-other-command-where-can-i-see-these-automatic-saves","title":"jj is said to record the working copy after jj log and every other command. Where can I see these automatic \"saves\"?","text":"

    Indeed, every jj command updates the current \"working-copy\" revision, marked with @ in jj log. You can notice this by how the commit ID of the working copy revision changes when it's updated. Note that, unless you move to another revision (with jj new or jj edit, for example), the change ID will not change.

    If you expected to see a historical view of your working copy changes in the parent-child relationships between commits you can see in jj log, this is simply not what they mean. What you can see in jj log is that after the working copy commit gets amended (after any edit), the commit ID changes.

    You can see the actual history of working copy changes using jj obslog. This will show the history of the commits that were previously the \"working-copy commit\", since the last time the change id of the working copy commit changed. The obsolete changes will be marked as \"hidden\". They are still accessible with any jj command (jj diff, for example), but you will need to use the commit id to refer to hidden commits.

    You can also use jj obslog -r on revisions that were previously the working-copy revisions (or on any other revisions). Use jj obslog -p as an easy way to see the evolution of the commit's contents.

    "},{"location":"FAQ/#can-i-prevent-jujutsu-from-recording-my-unfinished-work-im-not-ready-to-commit-it","title":"Can I prevent Jujutsu from recording my unfinished work? I'm not ready to commit it.","text":"

    Jujutsu automatically records new files in the current working-copy commit and doesn't provide a way to prevent that.

    However, you can easily record intermediate drafts of your work. If you think you might want to go back to the current state of the working-copy commit, simply use jj new. There's no need for the commit to be \"finished\" or even have a description.

    Then future edits will go into a new working-copy commit on top of the now former working-copy commit. Whenever you are happy with another set of edits, use jj squash to amend the previous commit.

    For more options see the next question.

    "},{"location":"FAQ/#can-i-interactively-create-a-new-commit-from-only-some-of-the-changes-in-the-working-copy-like-git-add-p-git-commit-or-hg-commit-i","title":"Can I interactively create a new commit from only some of the changes in the working copy, like git add -p && git commit or hg commit -i?","text":"

    Since the changes are already in the working-copy commit, the equivalent to git add -p && git commit/git commit -p/hg commit -i is to split the working-copy commit with jj split -i (or the practically identical jj commit -i).

    For the equivalent of git commit --amend -p/hg amend -i, use jj squash -i.

    "},{"location":"FAQ/#is-there-something-like-git-rebase-interactive-or-hg-histedit","title":"Is there something like git rebase --interactive or hg histedit?","text":"

    Not yet, you can check this issue for updates.

    To reorder commits, it is for now recommended to rebase commits individually, which may require multiple invocations of jj rebase -r or jj rebase -s.

    To squash or split commits, use jj squash and jj split.

    "},{"location":"FAQ/#how-can-i-keep-my-scratch-files-in-the-repository","title":"How can I keep my scratch files in the repository?","text":"

    You can keep your notes and other scratch files in the repository, if you add a wildcard pattern to either the repo's gitignore or your global gitignore. Something like *.scratch or *.scratchpad should do, after that rename the files you want to keep around to match the pattern.

    If $EDITOR integration is important, something like scratchpad.* may be more helpful, as you can keep the filename extension intact (it matches scratchpad.md, scratchpad.rs and more).

    You can find more details on gitignore files here.

    "},{"location":"FAQ/#how-can-i-keep-local-changes-around-but-not-use-them-for-pull-requests","title":"How can I keep local changes around, but not use them for Pull Requests?","text":"

    In general, you should separate out the changes to their own commit (using e.g. jj split). After that, one possible workflow is to rebase your pending PRs on top of the commit with the local changes. Then, just before pushing to a remote, use jj rebase -s child_of_commit_with_local_changes -d main to move the PRs back on top of main.

    If you have several PRs, you can try jj rebase -s all:commit_with_local_changes+ -d main (note the +) to move them all at once.

    An alternative workflow would be to rebase the commit with local changes on top of the PR you're working on and then do jj new commit_with_local_changes. You'll then need to use jj new --before to create new commits and jj squash --into to move new changes into the correct commits.

    "},{"location":"FAQ/#i-accidentally-changed-files-in-the-wrong-commit-how-do-i-move-the-recent-changes-into-another-commit","title":"I accidentally changed files in the wrong commit, how do I move the recent changes into another commit?","text":"

    Use jj obslog -p to see how your working-copy commit has evolved. Find the commit you want to restore the contents to. Let's say the current commit (with the changes intended for a new commit) are in commit X and the state you wanted is in commit Y. Note the commit id (normally in blue at the end of the line in the log output) of each of them. Now use jj new to create a new working-copy commit, then run jj restore --from Y --to @- to restore the parent commit to the old state, and jj restore --from X to restore the new working-copy commit to the new state.

    "},{"location":"FAQ/#how-do-i-resume-working-on-an-existing-change","title":"How do I resume working on an existing change?","text":"

    There are two ways to resume working on an earlier change: jj new then jj squash, and jj edit. The first is generally recommended, but jj edit can be useful. When you use jj edit, the revision is directly amended with your new changes, making it difficult to tell what exactly you change. You should avoid using jj edit when the revision has a conflict, as you may accidentally break the plain-text annotations on your state without realising.

    To start, use jj new <rev> to create a change based on that earlier revision. Make your edits, then use jj squash to update the earlier revision with those edits. For when you would use git stashing, use jj edit <rev> for expected behaviour. Other workflows may prefer jj edit as well.

    "},{"location":"FAQ/#how-do-i-deal-with-divergent-changes-after-the-change-id","title":"How do I deal with divergent changes ('??' after the change ID)?","text":"

    A divergent change represents a change that has two or more visible commits associated with it. To refer to such commits, you must use their commit ID. Most commonly, the way to resolve this is to abandon the unneeded commits (using jj abandon <commit ID>). If you would like to keep both commits with this change ID, you can jj duplicate one of them before abandoning it.

    Usually, the different commits associated with the divergent change ID should all appear in the log, but due to #2476, they may not. If that happens, you can either use jj log -r 'all()' | grep <change id> or disable the revsets.short-prefixes config option.

    "},{"location":"FAQ/#how-do-i-deal-with-conflicted-branches-after-branch-name","title":"How do I deal with conflicted branches ('??' after branch name)?","text":"

    A conflicted branch is a branch that refers to multiple different commits because jj couldn't fully resolve its desired position. Resolving conflicted branches is usually done by setting the branch to the correct commit using jj branch set <commit ID>.

    Usually, the different commits associated with the conflicted branch should all appear in the log, but if they don't you can use jj branch listto show all the commits associated with it.

    "},{"location":"FAQ/#how-do-i-integrate-jujutsu-with-gerrit","title":"How do I integrate Jujutsu with Gerrit?","text":"

    At the moment you'll need a script, which adds the required fields for Gerrit like the Change-Id footer. Then jj can invoke it via an $EDITOR override in an aliased command. Here's an example from an contributor (look for the jj signoff alias).

    After you have attached the Change-Id: footer to the commit series, you'll have to manually invoke git push of HEAD on the underlying git repository into the remote Gerrit branch refs/for/$BRANCH, where $BRANCH is the base branch you want your changes to go to (e.g., git push origin HEAD:refs/for/main). Using a co-located repo will make the underlying git repo directly accessible from the working directory.

    We hope to integrate with Gerrit natively in the future.

    "},{"location":"branches/","title":"Branches","text":""},{"location":"branches/#introduction","title":"Introduction","text":"

    Branches are named pointers to revisions (just like they are in Git). You can move them without affecting the target revision's identity. Branches automatically move when revisions are rewritten (e.g. by jj rebase). You can pass a branch's name to commands that want a revision as argument. For example, jj co main will check out the revision pointed to by the \"main\" branch. Use jj branch list to list branches and jj branch to create, move, or delete branches. There is currently no concept of an active/current/checked-out branch.

    "},{"location":"branches/#remotes-and-tracked-branches","title":"Remotes and tracked branches","text":"

    Jujutsu records the last seen position of a branch on each remote (just like Git's remote-tracking branches). This record is updated on every jj git fetch and jj git push of the branch. You can refer to the remembered remote branch positions with <branch name>@<remote name>, such as jj new main@origin. jj does not provide a way to manually edit these recorded positions.

    A remote branch can be associated with a local branch of the same name. This is called a tracked remote branch. When you pull a tracked branch from a remote, any changes compared to the current record of the remote's state will be propagated to the corresponding local branch, which will be created if it doesn't exist already.

    Details: how fetch pulls branches

    Let's say you run jj git fetch --remote origin and, during the fetch, jj determines that the remote's \"main\" branch has been moved so that its target is now ahead of the local record in main@origin.

    jj will then update main@origin to the new target. If main@origin is tracked, jj will also apply the change to the local branch main. If the local target has also been moved compared to main@origin (probably because you ran jj branch set main), then the two updates will be merged. If one is ahead of the other, then that target will become the new target. Otherwise, the local branch will become conflicted (see the \"Conflicts\" section below for details).

    Most commands don't show the tracked remote branch if it has the same target as the local branch. The local branch (without @<remote name>) is considered the branch's desired target. Consequently, if you want to update a branch on a remote, you first update the branch locally and then push the update to the remote. If a local branch also exists on some remote but points to a different target there, jj log will show the branch name with an asterisk suffix (e.g. main*). That is meant to remind you that you may want to push the branch to some remote.

    If you want to know the internals of branch tracking, consult the Design Doc.

    "},{"location":"branches/#terminology-summary","title":"Terminology summary","text":"
    • A remote branch is a branch ref on the remote. jj can find out its actual state only when it's actively communicating with the remote. However, jj does store the last-seen position of the remote branch; this is the commit jj show <branch name>@<remote name> would show. This notion is completely analogous to Git's \"remote-tracking branches\".
    • A tracked (remote) branch is defined above. You can make a remote branch tracked with the jj branch track command, for example.
    • A tracking (local) branch is the local branch that jj tries to keep in sync with the tracked remote branch. For example, after jj branch track mybranch@origin, there will be a local branch mybranch that's tracking the remote mybranch@origin branch. A local branch can track a branch of the same name on 0 or more remotes.

    The notion of tracked branches serves a similar function to the Git notion of an \"upstream branch\". Unlike Git, a single local branch can be tracking remote branches on multiple remotes, and the names of the local and remote branches must match.

    "},{"location":"branches/#manually-tracking-a-branch","title":"Manually tracking a branch","text":"

    To track a branch permanently use jj branch track <branch name>@<remote name>. It will now be imported as a local branch until you untrack it or it is deleted on the remote.

    Example:

    $ # List all available branches, as we want our colleague's branch.\n$ jj branch list --all\n$ # Find the branch.\n$ # [...]\n$ # Actually track the branch.\n$ jj branch track <branch name>@<remote name> # Example: jj branch track my-feature@origin\n$ # From this point on, <branch name> will be imported when fetching from <remote name>.\n$ jj git fetch --remote <remote name>\n$ # A local branch <branch name> should have been created or updated while fetching.\n$ jj new <branch name> # Do some local testing, etc.\n
    "},{"location":"branches/#untracking-a-branch","title":"Untracking a branch","text":"

    To stop following a remote branch, you can jj branch untrack it. After that, subsequent fetches of that remote will no longer move the local branch to match the position of the remote branch.

    Example:

    $ # List all local and remote branches.\n$ jj branch list --all\n$ # Find the branch we no longer want to track.\n$ # [...]\n# # Actually untrack it.\n$ jj branch untrack <branch name>@<remote name> # Example: jj branch untrack stuff@origin\n$ # From this point on, this remote branch won't be imported anymore.\n$ # The local branch (e.g. stuff) is unaffected. It may or may not still\n$ # be tracking branches on other remotes (e.g. stuff@upstream).\n
    "},{"location":"branches/#listing-tracked-branches","title":"Listing tracked branches","text":"

    To list tracked branches, you can jj branch list --tracked or jj branch list -t. This command omits local Git-tracking branches by default.

    You can see if a specific branch is tracked with jj branch list --tracked <branch name>.

    "},{"location":"branches/#automatic-tracking-of-branches-gitauto-local-branch-option","title":"Automatic tracking of branches & git.auto-local-branch option","text":"

    There are two situations where jj tracks branches automatically. jj git clone automatically sets up the default remote branch (e.g. main@origin) as tracked. When you push a local branch, the newly created branch on the remote is marked as tracked.

    By default, every other remote branch is marked as \"not tracked\" when it's fetched. If desired, you need to manually jj branch track them. This works well for repositories where multiple people work on a large number of branches.

    The default can be changed by setting the config git.auto-local-branch = true. Then, jj git fetch tracks every newly fetched branch with a local branch. Branches that already existed before the jj git fetch are not affected. This is similar to Mercurial, which fetches all its bookmarks (equivalent to Git branches) by default.

    "},{"location":"branches/#branch-movement","title":"Branch movement","text":"

    Currently Jujutsu automatically moves local branches when these conditions are met:

    • When a commit has been rewritten (e.g, when you rebase) branches and the working-copy will move along with it.
    • When a commit has been abandoned, all associated branches will be moved to its parent(s). If a working copy was pointing to the abandoned commit, then a new working-copy commit will be created on top of the parent(s).

    You could describe the movement as following along the change-id of the current branch commit, even if it isn't entirely accurate.

    "},{"location":"branches/#conflicts","title":"Conflicts","text":"

    Branches can end up in a conflicted state. When that happens, jj status will include information about the conflicted branches (and instructions for how to mitigate it). jj branch list will have details. jj log will show the branch name with a question mark suffix (e.g. main?) on each of the conflicted branch's potential target revisions. Using the branch name to look up a revision will resolve to all potential targets. That means that jj co main will error out, complaining that the revset resolved to multiple revisions.

    Both local branches (e.g. main) and the remote branch (e.g. main@origin) can have conflicts. Both can end up in that state if concurrent operations were run in the repo. The local branch more typically becomes conflicted because it was updated both locally and on a remote.

    To resolve a conflicted state in a local branch (e.g. main), you can move the branch to the desired target with jj branch. You may want to first either merge the conflicted targets with jj merge, or you may want to rebase one side on top of the other with jj rebase.

    To resolve a conflicted state in a remote branch (e.g. main@origin), simply pull from the remote (e.g. jj git fetch). The conflict resolution will also propagate to the local branch (which was presumably also conflicted).

    "},{"location":"cli-reference/","title":"CLI Reference","text":"

    Warning

    This CLI reference is experimental. It is automatically generated, but does not match the jj help output exactly.

    "},{"location":"cli-reference/#command-line-help-for-jj","title":"Command-Line Help for jj","text":"

    This document contains the help content for the jj command-line program.

    Command Overview:

    • jj\u21b4
    • jj abandon\u21b4
    • jj backout\u21b4
    • jj branch\u21b4
    • jj branch create\u21b4
    • jj branch delete\u21b4
    • jj branch forget\u21b4
    • jj branch list\u21b4
    • jj branch rename\u21b4
    • jj branch set\u21b4
    • jj branch track\u21b4
    • jj branch untrack\u21b4
    • jj cat\u21b4
    • jj chmod\u21b4
    • jj commit\u21b4
    • jj config\u21b4
    • jj config list\u21b4
    • jj config get\u21b4
    • jj config set\u21b4
    • jj config edit\u21b4
    • jj config path\u21b4
    • jj describe\u21b4
    • jj diff\u21b4
    • jj diffedit\u21b4
    • jj duplicate\u21b4
    • jj edit\u21b4
    • jj files\u21b4
    • jj git\u21b4
    • jj git remote\u21b4
    • jj git remote add\u21b4
    • jj git remote remove\u21b4
    • jj git remote rename\u21b4
    • jj git remote list\u21b4
    • jj git init\u21b4
    • jj git fetch\u21b4
    • jj git clone\u21b4
    • jj git push\u21b4
    • jj git import\u21b4
    • jj git export\u21b4
    • jj init\u21b4
    • jj interdiff\u21b4
    • jj log\u21b4
    • jj move\u21b4
    • jj new\u21b4
    • jj next\u21b4
    • jj obslog\u21b4
    • jj operation\u21b4
    • jj operation abandon\u21b4
    • jj operation log\u21b4
    • jj operation undo\u21b4
    • jj operation restore\u21b4
    • jj prev\u21b4
    • jj rebase\u21b4
    • jj resolve\u21b4
    • jj restore\u21b4
    • jj root\u21b4
    • jj show\u21b4
    • jj sparse\u21b4
    • jj sparse list\u21b4
    • jj sparse set\u21b4
    • jj sparse reset\u21b4
    • jj sparse edit\u21b4
    • jj split\u21b4
    • jj squash\u21b4
    • jj status\u21b4
    • jj tag\u21b4
    • jj tag list\u21b4
    • jj util\u21b4
    • jj util completion\u21b4
    • jj util gc\u21b4
    • jj util mangen\u21b4
    • jj util markdown-help\u21b4
    • jj util config-schema\u21b4
    • jj undo\u21b4
    • jj unsquash\u21b4
    • jj untrack\u21b4
    • jj version\u21b4
    • jj workspace\u21b4
    • jj workspace add\u21b4
    • jj workspace forget\u21b4
    • jj workspace list\u21b4
    • jj workspace root\u21b4
    • jj workspace update-stale\u21b4
    "},{"location":"cli-reference/#jj","title":"jj","text":"

    Jujutsu (An experimental VCS)

    To get started, see the tutorial at https://github.com/martinvonz/jj/blob/main/docs/tutorial.md.

    Usage: jj [OPTIONS] [COMMAND]

    "},{"location":"cli-reference/#subcommands","title":"Subcommands:","text":"
    • abandon \u2014 Abandon a revision
    • backout \u2014 Apply the reverse of a revision on top of another revision
    • branch \u2014 Manage branches
    • cat \u2014 Print contents of a file in a revision
    • chmod \u2014 Sets or removes the executable bit for paths in the repo
    • commit \u2014 Update the description and create a new change on top
    • config \u2014 Manage config options
    • describe \u2014 Update the change description or other metadata
    • diff \u2014 Compare file contents between two revisions
    • diffedit \u2014 Touch up the content changes in a revision with a diff editor
    • duplicate \u2014 Create a new change with the same content as an existing one
    • edit \u2014 Sets the specified revision as the working-copy revision
    • files \u2014 List files in a revision
    • git \u2014 Commands for working with the underlying Git repo
    • init \u2014 Create a new repo in the given directory
    • interdiff \u2014 Compare the changes of two commits
    • log \u2014 Show revision history
    • move \u2014 Move changes from one revision into another
    • new \u2014 Create a new, empty change and (by default) edit it in the working copy
    • next \u2014 Move the working-copy commit to the child revision
    • obslog \u2014 Show how a change has evolved
    • operation \u2014 Commands for working with the operation log
    • prev \u2014 Move the working-copy commit to the parent revision
    • rebase \u2014 Move revisions to different parent(s)
    • resolve \u2014 Resolve a conflicted file with an external merge tool
    • restore \u2014 Restore paths from another revision
    • root \u2014 Show the current workspace root directory
    • show \u2014 Show commit description and changes in a revision
    • sparse \u2014 Manage which paths from the working-copy commit are present in the working copy
    • split \u2014 Split a revision in two
    • squash \u2014 Move changes from a revision into another revision
    • status \u2014 Show high-level repo status
    • tag \u2014 Manage tags
    • util \u2014 Infrequently used commands such as for generating shell completions
    • undo \u2014 Undo an operation (shortcut for jj op undo)
    • unsquash \u2014 Move changes from a revision's parent into the revision
    • untrack \u2014 Stop tracking specified paths in the working copy
    • version \u2014 Display version information
    • workspace \u2014 Commands for working with workspaces
    "},{"location":"cli-reference/#options","title":"Options:","text":"
    • -R, --repository <REPOSITORY> \u2014 Path to repository to operate on
    • --ignore-working-copy \u2014 Don't snapshot the working copy, and don't update it

      Possible values: true, false

    • --at-operation <AT_OPERATION> \u2014 Operation to load the repo at

      Default value: @

    • --debug \u2014 Enable debug logging

      Possible values: true, false

    • --color <WHEN> \u2014 When to colorize output (always, never, auto)

    • --no-pager \u2014 Disable the pager

      Possible values: true, false

    • --config-toml <TOML> \u2014 Additional configuration options (can be repeated)

    "},{"location":"cli-reference/#jj-abandon","title":"jj abandon","text":"

    Abandon a revision

    Abandon a revision, rebasing descendants onto its parent(s). The behavior is similar to jj restore --changes-in; the difference is that jj abandon gives you a new change, while jj restore updates the existing change.

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj abandon [OPTIONS] [REVISIONS]...

    "},{"location":"cli-reference/#arguments","title":"Arguments:","text":"
    • <REVISIONS> \u2014 The revision(s) to abandon

      Default value: @

    "},{"location":"cli-reference/#options_1","title":"Options:","text":"
    • -s, --summary \u2014 Do not print every abandoned commit on a separate line

      Possible values: true, false

    • -r \u2014 Ignored (but lets you pass -r for consistency with other commands)

    "},{"location":"cli-reference/#jj-backout","title":"jj backout","text":"

    Apply the reverse of a revision on top of another revision

    Usage: jj backout [OPTIONS]

    "},{"location":"cli-reference/#options_2","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The revision to apply the reverse of

      Default value: @

    • -d, --destination <DESTINATION> \u2014 The revision to apply the reverse changes on top of

      Default value: @

    "},{"location":"cli-reference/#jj-branch","title":"jj branch","text":"

    Manage branches.

    For information about branches, see https://github.com/martinvonz/jj/blob/main/docs/branches.md.

    Usage: jj branch <COMMAND>

    "},{"location":"cli-reference/#subcommands_1","title":"Subcommands:","text":"
    • create \u2014 Create a new branch
    • delete \u2014 Delete an existing branch and propagate the deletion to remotes on the next push
    • forget \u2014 Forget everything about a branch, including its local and remote targets
    • list \u2014 List branches and their targets
    • rename \u2014 Rename old branch name to new branch name
    • set \u2014 Update an existing branch to point to a certain commit
    • track \u2014 Start tracking given remote branches
    • untrack \u2014 Stop tracking given remote branches
    "},{"location":"cli-reference/#jj-branch-create","title":"jj branch create","text":"

    Create a new branch

    Usage: jj branch create [OPTIONS] <NAMES>...

    "},{"location":"cli-reference/#arguments_1","title":"Arguments:","text":"
    • <NAMES> \u2014 The branches to create
    "},{"location":"cli-reference/#options_3","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The branch's target revision
    "},{"location":"cli-reference/#jj-branch-delete","title":"jj branch delete","text":"

    Delete an existing branch and propagate the deletion to remotes on the next push

    Usage: jj branch delete [NAMES]...

    "},{"location":"cli-reference/#arguments_2","title":"Arguments:","text":"
    • <NAMES> \u2014 The branches to delete
    "},{"location":"cli-reference/#options_4","title":"Options:","text":"
    • --glob <GLOB> \u2014 Deprecated. Please prefix the pattern with glob: instead
    "},{"location":"cli-reference/#jj-branch-forget","title":"jj branch forget","text":"

    Forget everything about a branch, including its local and remote targets.

    A forgotten branch will not impact remotes on future pushes. It will be recreated on future pulls if it still exists in the remote.

    Usage: jj branch forget [NAMES]...

    "},{"location":"cli-reference/#arguments_3","title":"Arguments:","text":"
    • <NAMES> \u2014 The branches to forget
    "},{"location":"cli-reference/#options_5","title":"Options:","text":"
    • --glob <GLOB> \u2014 Deprecated. Please prefix the pattern with glob: instead
    "},{"location":"cli-reference/#jj-branch-list","title":"jj branch list","text":"

    List branches and their targets

    By default, a tracking remote branch will be included only if its target is different from the local target. A non-tracking remote branch won't be listed. For a conflicted branch (both local and remote), old target revisions are preceded by a \"-\" and new target revisions are preceded by a \"+\".

    For information about branches, see https://github.com/martinvonz/jj/blob/main/docs/branches.md.

    Usage: jj branch list [OPTIONS] [NAMES]...

    "},{"location":"cli-reference/#arguments_4","title":"Arguments:","text":"
    • <NAMES> \u2014 Show branches whose local name matches
    "},{"location":"cli-reference/#options_6","title":"Options:","text":"
    • -a, --all-remotes \u2014 Show all tracking and non-tracking remote branches including the ones whose targets are synchronized with the local branches

      Possible values: true, false

    • -t, --tracked \u2014 Show remote tracked branches only. Omits local Git-tracking branches by default

      Possible values: true, false

    • -c, --conflicted \u2014 Show conflicted branches only

      Possible values: true, false

    • -r, --revisions <REVISIONS> \u2014 Show branches whose local targets are in the given revisions

    "},{"location":"cli-reference/#jj-branch-rename","title":"jj branch rename","text":"

    Rename old branch name to new branch name.

    The new branch name points at the same commit as the old branch name.

    Usage: jj branch rename <OLD> <NEW>

    "},{"location":"cli-reference/#arguments_5","title":"Arguments:","text":"
    • <OLD> \u2014 The old name of the branch
    • <NEW> \u2014 The new name of the branch
    "},{"location":"cli-reference/#jj-branch-set","title":"jj branch set","text":"

    Update an existing branch to point to a certain commit

    Usage: jj branch set [OPTIONS] <NAMES>...

    "},{"location":"cli-reference/#arguments_6","title":"Arguments:","text":"
    • <NAMES> \u2014 The branches to update
    "},{"location":"cli-reference/#options_7","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The branch's target revision
    • -B, --allow-backwards \u2014 Allow moving the branch backwards or sideways

      Possible values: true, false

    "},{"location":"cli-reference/#jj-branch-track","title":"jj branch track","text":"

    Start tracking given remote branches

    A tracking remote branch will be imported as a local branch of the same name. Changes to it will propagate to the existing local branch on future pulls.

    Usage: jj branch track <BRANCH@REMOTE>...

    "},{"location":"cli-reference/#arguments_7","title":"Arguments:","text":"
    • <BRANCH@REMOTE> \u2014 Remote branches to track
    "},{"location":"cli-reference/#jj-branch-untrack","title":"jj branch untrack","text":"

    Stop tracking given remote branches

    A non-tracking remote branch is just a pointer to the last-fetched remote branch. It won't be imported as a local branch on future pulls.

    Usage: jj branch untrack <BRANCH@REMOTE>...

    "},{"location":"cli-reference/#arguments_8","title":"Arguments:","text":"
    • <BRANCH@REMOTE> \u2014 Remote branches to untrack
    "},{"location":"cli-reference/#jj-cat","title":"jj cat","text":"

    Print contents of a file in a revision

    Usage: jj cat [OPTIONS] <PATH>

    "},{"location":"cli-reference/#arguments_9","title":"Arguments:","text":"
    • <PATH> \u2014 The file to print
    "},{"location":"cli-reference/#options_8","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The revision to get the file contents from

      Default value: @

    "},{"location":"cli-reference/#jj-chmod","title":"jj chmod","text":"

    Sets or removes the executable bit for paths in the repo

    Unlike the POSIX chmod, jj chmod also works on Windows, on conflicted files, and on arbitrary revisions.

    Usage: jj chmod [OPTIONS] <MODE> <PATHS>...

    "},{"location":"cli-reference/#arguments_10","title":"Arguments:","text":"
    • <MODE>

      Possible values:

      • n: Make a path non-executable (alias: normal)
      • x: Make a path executable (alias: executable)
    • <PATHS> \u2014 Paths to change the executable bit for

    "},{"location":"cli-reference/#options_9","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The revision to update

      Default value: @

    "},{"location":"cli-reference/#jj-commit","title":"jj commit","text":"

    Update the description and create a new change on top

    Usage: jj commit [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_11","title":"Arguments:","text":"
    • <PATHS> \u2014 Put these paths in the first commit
    "},{"location":"cli-reference/#options_10","title":"Options:","text":"
    • -i, --interactive \u2014 Interactively choose which changes to include in the first commit

      Possible values: true, false

    • --tool <NAME> \u2014 Specify diff editor to be used (implies --interactive)

    • -m, --message <MESSAGE> \u2014 The change description to use (don't open editor)
    "},{"location":"cli-reference/#jj-config","title":"jj config","text":"

    Manage config options

    Operates on jj configuration, which comes from the config file and environment variables.

    For file locations, supported config options, and other details about jj config, see https://github.com/martinvonz/jj/blob/main/docs/config.md.

    Usage: jj config <COMMAND>

    "},{"location":"cli-reference/#subcommands_2","title":"Subcommands:","text":"
    • list \u2014 List variables set in config file, along with their values
    • get \u2014 Get the value of a given config option.
    • set \u2014 Update config file to set the given option to a given value
    • edit \u2014 Start an editor on a jj config file
    • path \u2014 Print the path to the config file
    "},{"location":"cli-reference/#jj-config-list","title":"jj config list","text":"

    List variables set in config file, along with their values

    Usage: jj config list [OPTIONS] [NAME]

    "},{"location":"cli-reference/#arguments_12","title":"Arguments:","text":"
    • <NAME> \u2014 An optional name of a specific config option to look up
    "},{"location":"cli-reference/#options_11","title":"Options:","text":"
    • --include-defaults \u2014 Whether to explicitly include built-in default values in the list

      Possible values: true, false

    • --include-overridden \u2014 Allow printing overridden values

      Possible values: true, false

    • --user \u2014 Target the user-level config

      Possible values: true, false

    • --repo \u2014 Target the repo-level config

      Possible values: true, false

    • -T, --template <TEMPLATE> \u2014 Render each variable using the given template

    "},{"location":"cli-reference/#jj-config-get","title":"jj config get","text":"

    Get the value of a given config option.

    Unlike jj config list, the result of jj config get is printed without extra formatting and therefore is usable in scripting. For example:

    $ jj config list user.name user.name=\"Martin von Zweigbergk\" $ jj config get user.name Martin von Zweigbergk

    Usage: jj config get <NAME>

    "},{"location":"cli-reference/#arguments_13","title":"Arguments:","text":"
    • <NAME>
    "},{"location":"cli-reference/#jj-config-set","title":"jj config set","text":"

    Update config file to set the given option to a given value

    Usage: jj config set <--user|--repo> <NAME> <VALUE>

    "},{"location":"cli-reference/#arguments_14","title":"Arguments:","text":"
    • <NAME>
    • <VALUE>
    "},{"location":"cli-reference/#options_12","title":"Options:","text":"
    • --user \u2014 Target the user-level config

      Possible values: true, false

    • --repo \u2014 Target the repo-level config

      Possible values: true, false

    "},{"location":"cli-reference/#jj-config-edit","title":"jj config edit","text":"

    Start an editor on a jj config file.

    Creates the file if it doesn't already exist regardless of what the editor does.

    Usage: jj config edit <--user|--repo>

    "},{"location":"cli-reference/#options_13","title":"Options:","text":"
    • --user \u2014 Target the user-level config

      Possible values: true, false

    • --repo \u2014 Target the repo-level config

      Possible values: true, false

    "},{"location":"cli-reference/#jj-config-path","title":"jj config path","text":"

    Print the path to the config file

    A config file at that path may or may not exist.

    See jj config edit if you'd like to immediately edit the file.

    Usage: jj config path <--user|--repo>

    "},{"location":"cli-reference/#options_14","title":"Options:","text":"
    • --user \u2014 Target the user-level config

      Possible values: true, false

    • --repo \u2014 Target the repo-level config

      Possible values: true, false

    "},{"location":"cli-reference/#jj-describe","title":"jj describe","text":"

    Update the change description or other metadata

    Starts an editor to let you edit the description of a change. The editor will be $EDITOR, or pico if that's not defined (Notepad on Windows).

    Usage: jj describe [OPTIONS] [REVISION]

    "},{"location":"cli-reference/#arguments_15","title":"Arguments:","text":"
    • <REVISION> \u2014 The revision whose description to edit

      Default value: @

    "},{"location":"cli-reference/#options_15","title":"Options:","text":"
    • -r \u2014 Ignored (but lets you pass -r for consistency with other commands)

      Possible values: true, false

    • -m, --message <MESSAGE> \u2014 The change description to use (don't open editor)

    • --stdin \u2014 Read the change description from stdin

      Possible values: true, false

    • --no-edit \u2014 Don't open an editor

      Possible values: true, false

    • --reset-author \u2014 Reset the author to the configured user

      Possible values: true, false

    "},{"location":"cli-reference/#jj-diff","title":"jj diff","text":"

    Compare file contents between two revisions

    With the -r option, which is the default, shows the changes compared to the parent revision. If there are several parent revisions (i.e., the given revision is a merge), then they will be merged and the changes from the result to the given revision will be shown.

    With the --from and/or --to options, shows the difference from/to the given revisions. If either is left out, it defaults to the working-copy commit. For example, jj diff --from main shows the changes from \"main\" (perhaps a branch name) to the working-copy commit.

    Usage: jj diff [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_16","title":"Arguments:","text":"
    • <PATHS> \u2014 Restrict the diff to these paths
    "},{"location":"cli-reference/#options_16","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 Show changes in this revision, compared to its parent(s)
    • --from <FROM> \u2014 Show changes from this revision
    • --to <TO> \u2014 Show changes to this revision
    • -s, --summary \u2014 For each path, show only whether it was modified, added, or deleted

      Possible values: true, false

    • --stat \u2014 Show a histogram of the changes

      Possible values: true, false

    • --types \u2014 For each path, show only its type before and after

      Possible values: true, false

    • --git \u2014 Show a Git-format diff

      Possible values: true, false

    • --color-words \u2014 Show a word-level diff with changes indicated only by color

      Possible values: true, false

    • --tool <TOOL> \u2014 Generate diff by external command

    • --context <CONTEXT> \u2014 Number of lines of context to show
    "},{"location":"cli-reference/#jj-diffedit","title":"jj diffedit","text":"

    Touch up the content changes in a revision with a diff editor

    With the -r option, which is the default, starts a diff editor (meld by default) on the changes in the revision.

    With the --from and/or --to options, starts a diff editor comparing the \"from\" revision to the \"to\" revision.

    Edit the right side of the diff until it looks the way you want. Once you close the editor, the revision specified with -r or --to will be updated. Descendants will be rebased on top as usual, which may result in conflicts.

    See jj restore if you want to move entire files from one revision to another. See jj squash -i or jj unsquash -i if you instead want to move changes into or out of the parent revision.

    Usage: jj diffedit [OPTIONS]

    "},{"location":"cli-reference/#options_17","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The revision to touch up. Defaults to @ if neither --to nor --from are specified
    • --from <FROM> \u2014 Show changes from this revision. Defaults to @ if --to is specified
    • --to <TO> \u2014 Edit changes in this revision. Defaults to @ if --from is specified
    • --tool <NAME> \u2014 Specify diff editor to be used
    "},{"location":"cli-reference/#jj-duplicate","title":"jj duplicate","text":"

    Create a new change with the same content as an existing one

    Usage: jj duplicate [REVISIONS]...

    "},{"location":"cli-reference/#arguments_17","title":"Arguments:","text":"
    • <REVISIONS> \u2014 The revision(s) to duplicate

      Default value: @

    "},{"location":"cli-reference/#options_18","title":"Options:","text":"
    • -r \u2014 Ignored (but lets you pass -r for consistency with other commands)
    "},{"location":"cli-reference/#jj-edit","title":"jj edit","text":"

    Sets the specified revision as the working-copy revision

    Note: it is generally recommended to instead use jj new and jj squash.

    For more information, see https://martinvonz.github.io/jj/latest/FAQ#how-do-i-resume-working-on-an-existing-change

    Usage: jj edit <REVISION>

    "},{"location":"cli-reference/#arguments_18","title":"Arguments:","text":"
    • <REVISION> \u2014 The commit to edit
    "},{"location":"cli-reference/#options_19","title":"Options:","text":"
    • -r \u2014 Ignored (but lets you pass -r for consistency with other commands)

      Possible values: true, false

    "},{"location":"cli-reference/#jj-files","title":"jj files","text":"

    List files in a revision

    Usage: jj files [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_19","title":"Arguments:","text":"
    • <PATHS> \u2014 Only list files matching these prefixes (instead of all files)
    "},{"location":"cli-reference/#options_20","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The revision to list files in

      Default value: @

    "},{"location":"cli-reference/#jj-git","title":"jj git","text":"

    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.

    Usage: jj git <COMMAND>

    "},{"location":"cli-reference/#subcommands_3","title":"Subcommands:","text":"
    • remote \u2014 Manage Git remotes
    • init \u2014 Create a new Git backed repo
    • fetch \u2014 Fetch from a Git remote
    • clone \u2014 Create a new repo backed by a clone of a Git repo
    • push \u2014 Push to a Git remote
    • import \u2014 Update repo with changes made in the underlying Git repo
    • export \u2014 Update the underlying Git repo with changes made in the repo
    "},{"location":"cli-reference/#jj-git-remote","title":"jj git remote","text":"

    Manage Git remotes

    The Git repo will be a bare git repo stored inside the .jj/ directory.

    Usage: jj git remote <COMMAND>

    "},{"location":"cli-reference/#subcommands_4","title":"Subcommands:","text":"
    • add \u2014 Add a Git remote
    • remove \u2014 Remove a Git remote and forget its branches
    • rename \u2014 Rename a Git remote
    • list \u2014 List Git remotes
    "},{"location":"cli-reference/#jj-git-remote-add","title":"jj git remote add","text":"

    Add a Git remote

    Usage: jj git remote add <REMOTE> <URL>

    "},{"location":"cli-reference/#arguments_20","title":"Arguments:","text":"
    • <REMOTE> \u2014 The remote's name
    • <URL> \u2014 The remote's URL
    "},{"location":"cli-reference/#jj-git-remote-remove","title":"jj git remote remove","text":"

    Remove a Git remote and forget its branches

    Usage: jj git remote remove <REMOTE>

    "},{"location":"cli-reference/#arguments_21","title":"Arguments:","text":"
    • <REMOTE> \u2014 The remote's name
    "},{"location":"cli-reference/#jj-git-remote-rename","title":"jj git remote rename","text":"

    Rename a Git remote

    Usage: jj git remote rename <OLD> <NEW>

    "},{"location":"cli-reference/#arguments_22","title":"Arguments:","text":"
    • <OLD> \u2014 The name of an existing remote
    • <NEW> \u2014 The desired name for old
    "},{"location":"cli-reference/#jj-git-remote-list","title":"jj git remote list","text":"

    List Git remotes

    Usage: jj git remote list

    "},{"location":"cli-reference/#jj-git-init","title":"jj git init","text":"

    Create a new Git backed repo

    Usage: jj git init [OPTIONS] [DESTINATION]

    "},{"location":"cli-reference/#arguments_23","title":"Arguments:","text":"
    • <DESTINATION> \u2014 The destination directory where the jj repo will be created. If the directory does not exist, it will be created. If no directory is diven, the current directory is used

      Default value: .

    "},{"location":"cli-reference/#options_21","title":"Options:","text":"
    • --colocate \u2014 Specifies that the jj repo should also be a valid git repo, allowing the use of both jj and git commands in the same directory

      Possible values: true, false

    • --git-repo <GIT_REPO> \u2014 Specifies a path to an existing git repository to be used as the backing git repo for the newly created jj repo

    "},{"location":"cli-reference/#jj-git-fetch","title":"jj git fetch","text":"

    Fetch from a Git remote

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj git fetch [OPTIONS]

    "},{"location":"cli-reference/#options_22","title":"Options:","text":"
    • -b, --branch <BRANCH> \u2014 Fetch only some of the branches

      Default value: glob:*

    • --remote <remote> \u2014 The remote to fetch from (only named remotes are supported, can be repeated)

    • --all-remotes \u2014 Fetch from all remotes

      Possible values: true, false

    "},{"location":"cli-reference/#jj-git-clone","title":"jj git clone","text":"

    Create a new repo backed by a clone of a Git repo

    The Git repo will be a bare git repo stored inside the .jj/ directory.

    Usage: jj git clone [OPTIONS] <SOURCE> [DESTINATION]

    "},{"location":"cli-reference/#arguments_24","title":"Arguments:","text":"
    • <SOURCE> \u2014 URL or path of the Git repo to clone
    • <DESTINATION> \u2014 The directory to write the Jujutsu repo to
    "},{"location":"cli-reference/#options_23","title":"Options:","text":"
    • --colocate \u2014 Whether or not to colocate the Jujutsu repo with the git repo

      Possible values: true, false

    "},{"location":"cli-reference/#jj-git-push","title":"jj git push","text":"

    Push to a Git remote

    By default, pushes any branches pointing to remote_branches(remote=<remote>)..@. Use --branch to push specific branches. Use --all to push all branches. Use --change to generate branch names based on the change IDs of specific commits.

    Usage: jj git push [OPTIONS]

    "},{"location":"cli-reference/#options_24","title":"Options:","text":"
    • --remote <REMOTE> \u2014 The remote to push to (only named remotes are supported)
    • -b, --branch <BRANCH> \u2014 Push only this branch, or branches matching a pattern (can be repeated)
    • --all \u2014 Push all branches (including deleted branches)

      Possible values: true, false

    • --tracked \u2014 Push all tracked branches (including deleted branches)

      Possible values: true, false

    • --deleted \u2014 Push all deleted branches

      Possible values: true, false

    • -r, --revisions <REVISIONS> \u2014 Push branches pointing to these commits (can be repeated)

    • -c, --change <CHANGE> \u2014 Push this commit by creating a branch based on its change ID (can be repeated)
    • --dry-run \u2014 Only display what will change on the remote

      Possible values: true, false

    "},{"location":"cli-reference/#jj-git-import","title":"jj git import","text":"

    Update repo with changes made in the underlying Git repo

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj git import

    "},{"location":"cli-reference/#jj-git-export","title":"jj git export","text":"

    Update the underlying Git repo with changes made in the repo

    Usage: jj git export

    "},{"location":"cli-reference/#jj-init","title":"jj init","text":"

    Create a new repo in the given directory

    If the given directory does not exist, it will be created. If no directory is given, the current directory is used.

    Usage: jj init [DESTINATION]

    "},{"location":"cli-reference/#arguments_25","title":"Arguments:","text":"
    • <DESTINATION> \u2014 The destination directory

      Default value: .

    "},{"location":"cli-reference/#options_25","title":"Options:","text":"
    • --git \u2014 DEPRECATED: Use jj git init Use the Git backend, creating a jj repo backed by a Git repo

      Possible values: true, false

    • --git-repo <GIT_REPO> \u2014 DEPRECATED: Use jj git init Path to a git repo the jj repo will be backed by

    "},{"location":"cli-reference/#jj-interdiff","title":"jj interdiff","text":"

    Compare the changes of two commits

    This excludes changes from other commits by temporarily rebasing --from onto --to's parents. If you wish to compare the same change across versions, consider jj obslog -p instead.

    Usage: jj interdiff [OPTIONS] <--from <FROM>|--to <TO>> [PATHS]...

    "},{"location":"cli-reference/#arguments_26","title":"Arguments:","text":"
    • <PATHS> \u2014 Restrict the diff to these paths
    "},{"location":"cli-reference/#options_26","title":"Options:","text":"
    • --from <FROM> \u2014 Show changes from this revision
    • --to <TO> \u2014 Show changes to this revision
    • -s, --summary \u2014 For each path, show only whether it was modified, added, or deleted

      Possible values: true, false

    • --stat \u2014 Show a histogram of the changes

      Possible values: true, false

    • --types \u2014 For each path, show only its type before and after

      Possible values: true, false

    • --git \u2014 Show a Git-format diff

      Possible values: true, false

    • --color-words \u2014 Show a word-level diff with changes indicated only by color

      Possible values: true, false

    • --tool <TOOL> \u2014 Generate diff by external command

    • --context <CONTEXT> \u2014 Number of lines of context to show
    "},{"location":"cli-reference/#jj-log","title":"jj log","text":"

    Show revision history

    Renders a graphical view of the project's history, ordered with children before parents. By default, the output only includes mutable revisions, along with some additional revisions for context.

    Spans of revisions that are not included in the graph per --revisions are rendered as a synthetic node labeled \"(elided revisions)\".

    Usage: jj log [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_27","title":"Arguments:","text":"
    • <PATHS> \u2014 Show revisions modifying the given paths
    "},{"location":"cli-reference/#options_27","title":"Options:","text":"
    • -r, --revisions <REVISIONS> \u2014 Which revisions to show. Defaults to the revsets.log setting, or @ | ancestors(immutable_heads().., 2) | trunk() if it is not set
    • --reversed \u2014 Show revisions in the opposite order (older revisions first)

      Possible values: true, false

    • -l, --limit <LIMIT> \u2014 Limit number of revisions to show

    • --no-graph \u2014 Don't show the graph, show a flat list of revisions

      Possible values: true, false

    • -T, --template <TEMPLATE> \u2014 Render each revision using the given template

    • -p, --patch \u2014 Show patch

      Possible values: true, false

    • -s, --summary \u2014 For each path, show only whether it was modified, added, or deleted

      Possible values: true, false

    • --stat \u2014 Show a histogram of the changes

      Possible values: true, false

    • --types \u2014 For each path, show only its type before and after

      Possible values: true, false

    • --git \u2014 Show a Git-format diff

      Possible values: true, false

    • --color-words \u2014 Show a word-level diff with changes indicated only by color

      Possible values: true, false

    • --tool <TOOL> \u2014 Generate diff by external command

    • --context <CONTEXT> \u2014 Number of lines of context to show
    "},{"location":"cli-reference/#jj-move","title":"jj move","text":"

    Move changes from one revision into another

    Use --interactive to move only part of the source revision into the destination. The selected changes (or all the changes in the source revision if not using --interactive) will be moved into the destination. The changes will be removed from the source. If that means that the source is now empty compared to its parent, it will be abandoned. Without --interactive, the source change will always be empty.

    If the source became empty and both the source and destination had a non-empty description, you will be asked for the combined description. If either was empty, then the other one will be used.

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj move [OPTIONS] <--from <FROM>|--to <TO>> [PATHS]...

    "},{"location":"cli-reference/#arguments_28","title":"Arguments:","text":"
    • <PATHS> \u2014 Move only changes to these paths (instead of all paths)
    "},{"location":"cli-reference/#options_28","title":"Options:","text":"
    • -f, --from <FROM> \u2014 Move part of this change into the destination
    • -t, --to <TO> \u2014 Move part of the source into this change
    • -i, --interactive \u2014 Interactively choose which parts to move

      Possible values: true, false

    • --tool <NAME> \u2014 Specify diff editor to be used (implies --interactive)

    "},{"location":"cli-reference/#jj-new","title":"jj new","text":"

    Create a new, empty change and (by default) edit it in the working copy

    By default, jj will edit the new change, making the working copy represent the new commit. This can be avoided with --no-edit.

    Note that you can create a merge commit by specifying multiple revisions as argument. For example, jj new main @ will create a new commit with the main branch and the working copy as parents.

    For more information, see https://github.com/martinvonz/jj/blob/main/docs/working-copy.md.

    Usage: jj new [OPTIONS] [REVISIONS]...

    "},{"location":"cli-reference/#arguments_29","title":"Arguments:","text":"
    • <REVISIONS> \u2014 Parent(s) of the new change

      Default value: @

    "},{"location":"cli-reference/#options_29","title":"Options:","text":"
    • -r \u2014 Ignored (but lets you pass -r for consistency with other commands)
    • -m, --message <MESSAGE> \u2014 The change description to use
    • -L, --allow-large-revsets \u2014 Deprecated. Please prefix the revset with all: instead

      Possible values: true, false

    • --no-edit \u2014 Do not edit the newly created change

      Possible values: true, false

    • --edit \u2014 No-op flag to pair with --no-edit

      Possible values: true, false

    • -A, --insert-after \u2014 Insert the new change between the target commit(s) and their children

      Possible values: true, false

    • -B, --insert-before \u2014 Insert the new change between the target commit(s) and their parents

      Possible values: true, false

    "},{"location":"cli-reference/#jj-next","title":"jj next","text":"

    Move the working-copy commit to the child revision

    The command moves you to the next child in a linear fashion.

    D      D @\n|      |/\nC @ => C\n|/     |\nB      B\n

    If --edit is passed, it will move you directly to the child revision.

    D    D\n|    |\nC    C\n|    |\nB => @\n|    |\n@    A\n\nIf your working-copy commit already has visible children, then `--edit` is\nimplied.\n

    Usage: jj next [OPTIONS] [AMOUNT]

    "},{"location":"cli-reference/#arguments_30","title":"Arguments:","text":"
    • <AMOUNT> \u2014 How many revisions to move forward. By default advances to the next child

      Default value: 1

    "},{"location":"cli-reference/#options_30","title":"Options:","text":"
    • --edit \u2014 Instead of creating a new working-copy commit on top of the target commit (like jj new), edit the target commit directly (like jj edit)

      Possible values: true, false

    "},{"location":"cli-reference/#jj-obslog","title":"jj obslog","text":"

    Show how a change has evolved

    Show how a change has evolved as it's been updated, rebased, etc.

    Usage: jj obslog [OPTIONS]

    "},{"location":"cli-reference/#options_31","title":"Options:","text":"
    • -r, --revision <REVISION>

      Default value: @

    • -l, --limit <LIMIT> \u2014 Limit number of revisions to show

    • --no-graph \u2014 Don't show the graph, show a flat list of revisions

      Possible values: true, false

    • -T, --template <TEMPLATE> \u2014 Render each revision using the given template

    • -p, --patch \u2014 Show patch compared to the previous version of this change

      Possible values: true, false

    • -s, --summary \u2014 For each path, show only whether it was modified, added, or deleted

      Possible values: true, false

    • --stat \u2014 Show a histogram of the changes

      Possible values: true, false

    • --types \u2014 For each path, show only its type before and after

      Possible values: true, false

    • --git \u2014 Show a Git-format diff

      Possible values: true, false

    • --color-words \u2014 Show a word-level diff with changes indicated only by color

      Possible values: true, false

    • --tool <TOOL> \u2014 Generate diff by external command

    • --context <CONTEXT> \u2014 Number of lines of context to show
    "},{"location":"cli-reference/#jj-operation","title":"jj operation","text":"

    Commands for working with the operation log

    For information about the operation log, see https://github.com/martinvonz/jj/blob/main/docs/operation-log.md.

    Usage: jj operation <COMMAND>

    "},{"location":"cli-reference/#subcommands_5","title":"Subcommands:","text":"
    • abandon \u2014 Abandon operation history
    • log \u2014 Show the operation log
    • undo \u2014 Create a new operation that undoes an earlier operation
    • restore \u2014 Create a new operation that restores the repo to an earlier state
    "},{"location":"cli-reference/#jj-operation-abandon","title":"jj operation abandon","text":"

    Abandon operation history

    To discard old operation history, use jj op abandon ..<operation ID>. It will abandon the specified operation and all its ancestors. The descendants will be reparented onto the root operation.

    To discard recent operations, use jj op restore <operation ID> followed by jj op abandon <operation ID>..@-.

    The abandoned operations, commits, and other unreachable objects can later be garbage collected by using jj util gc command.

    Usage: jj operation abandon <OPERATION>

    "},{"location":"cli-reference/#arguments_31","title":"Arguments:","text":"
    • <OPERATION> \u2014 The operation or operation range to abandon
    "},{"location":"cli-reference/#jj-operation-log","title":"jj operation log","text":"

    Show the operation log

    Usage: jj operation log [OPTIONS]

    "},{"location":"cli-reference/#options_32","title":"Options:","text":"
    • -l, --limit <LIMIT> \u2014 Limit number of operations to show
    • --no-graph \u2014 Don't show the graph, show a flat list of operations

      Possible values: true, false

    • -T, --template <TEMPLATE> \u2014 Render each operation using the given template

    "},{"location":"cli-reference/#jj-operation-undo","title":"jj operation undo","text":"

    Create a new operation that undoes an earlier operation

    This undoes an individual operation by applying the inverse of the operation.

    Usage: jj operation undo [OPTIONS] [OPERATION]

    "},{"location":"cli-reference/#arguments_32","title":"Arguments:","text":"
    • <OPERATION> \u2014 The operation to undo

      Default value: @

    "},{"location":"cli-reference/#options_33","title":"Options:","text":"
    • --what <WHAT> \u2014 What portions of the local state to restore (can be repeated)

      Default values: repo, remote-tracking

      Possible values:

      • repo: The jj repo state and local branches
      • remote-tracking: The remote-tracking branches. Do not restore these if you'd like to push after the undo
    "},{"location":"cli-reference/#jj-operation-restore","title":"jj operation restore","text":"

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

    This restores the repo to the state at the specified operation, effectively undoing all later operations. It does so by creating a new operation.

    Usage: jj operation restore [OPTIONS] <OPERATION>

    "},{"location":"cli-reference/#arguments_33","title":"Arguments:","text":"
    • <OPERATION> \u2014 The operation to restore to
    "},{"location":"cli-reference/#options_34","title":"Options:","text":"
    • --what <WHAT> \u2014 What portions of the local state to restore (can be repeated)

      Default values: repo, remote-tracking

      Possible values:

      • repo: The jj repo state and local branches
      • remote-tracking: The remote-tracking branches. Do not restore these if you'd like to push after the undo
    "},{"location":"cli-reference/#jj-prev","title":"jj prev","text":"

    Move the working-copy commit to the parent revision

    The command moves you to the parent in a linear fashion.

    D @  D\n|/   |\nA => A @\n|    |/\nB    B\n

    If --edit is passed, it will move the working copy commit directly to the parent.

    D @  D\n|/   |\nC => @\n|    |\nB    B\n|    |\nA    A\n\nIf your working-copy commit already has visible children, then `--edit` is\nimplied.\n

    Usage: jj prev [OPTIONS] [AMOUNT]

    "},{"location":"cli-reference/#arguments_34","title":"Arguments:","text":"
    • <AMOUNT> \u2014 How many revisions to move backward. By default moves to the parent

      Default value: 1

    "},{"location":"cli-reference/#options_35","title":"Options:","text":"
    • --edit \u2014 Edit the parent directly, instead of moving the working-copy commit

      Possible values: true, false

    "},{"location":"cli-reference/#jj-rebase","title":"jj rebase","text":"

    Move revisions to different parent(s)

    There are three different ways of specifying which revisions to rebase: -b to rebase a whole branch, -s to rebase a revision and its descendants, and -r to rebase a single commit. If none of them is specified, it defaults to -b @.

    With -s, the command rebases the specified revision and its descendants onto the destination. For example, jj rebase -s M -d O would transform your history like this (letters followed by an apostrophe are post-rebase versions):

    O           N'\n|           |\n| N         M'\n| |         |\n| M         O\n| |    =>   |\n| | L       | L\n| |/        | |\n| K         | K\n|/          |/\nJ           J\n

    With -b, the command rebases the whole \"branch\" containing the specified revision. A \"branch\" is the set of commits that includes:

    • the specified revision and ancestors that are not also ancestors of the destination
    • all descendants of those commits

    In other words, jj rebase -b X -d Y rebases commits in the revset (Y..X):: (which is equivalent to jj rebase -s 'roots(Y..X)' -d Y for a single root). For example, either jj rebase -b L -d O or jj rebase -b M -d O would transform your history like this (because L and M are on the same \"branch\", relative to the destination):

    O           N'\n|           |\n| N         M'\n| |         |\n| M         | L'\n| |    =>   |/\n| | L       K'\n| |/        |\n| K         O\n|/          |\nJ           J\n

    With -r, the command rebases only the specified revision onto the destination. Any \"hole\" left behind will be filled by rebasing descendants onto the specified revision's parent(s). For example, jj rebase -r K -d M would transform your history like this:

    M          K'\n|          |\n| L        M\n| |   =>   |\n| K        | L'\n|/         |/\nJ          J\n

    Note that you can create a merge commit by repeating the -d argument. For example, if you realize that commit L actually depends on commit M in order to work (in addition to its current parent K), you can run jj rebase -s L -d K -d M:

    M          L'\n|          |\\\n| L        M |\n| |   =>   | |\n| K        | K\n|/         |/\nJ          J\n

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj rebase [OPTIONS] --destination <DESTINATION>

    "},{"location":"cli-reference/#options_36","title":"Options:","text":"
    • -b, --branch <BRANCH> \u2014 Rebase the whole branch relative to destination's ancestors (can be repeated)
    • -s, --source <SOURCE> \u2014 Rebase specified revision(s) together with their trees of descendants (can be repeated)
    • -r, --revision <REVISION> \u2014 Rebase only this revision, rebasing descendants onto this revision's parent(s)
    • -d, --destination <DESTINATION> \u2014 The revision(s) to rebase onto (can be repeated to create a merge commit)
    • --skip-empty \u2014 If true, when rebasing would produce an empty commit, the commit is abandoned. It will not be abandoned if it was already empty before the rebase. Will never skip merge commits with multiple non-empty parents

      Possible values: true, false

    • -L, --allow-large-revsets \u2014 Deprecated. Please prefix the revset with all: instead

      Possible values: true, false

    "},{"location":"cli-reference/#jj-resolve","title":"jj resolve","text":"

    Resolve a conflicted file with an external merge tool

    Only conflicts that can be resolved with a 3-way merge are supported. See docs for merge tool configuration instructions.

    Note that conflicts can also be resolved without using this command. You may edit the conflict markers in the conflicted file directly with a text editor.

    Usage: jj resolve [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_35","title":"Arguments:","text":"
    • <PATHS> \u2014 Restrict to these paths when searching for a conflict to resolve. We will attempt to resolve the first conflict we can find. You can use the --list argument to find paths to use here
    "},{"location":"cli-reference/#options_37","title":"Options:","text":"
    • -r, --revision <REVISION>

      Default value: @

    • -l, --list \u2014 Instead of resolving one conflict, list all the conflicts

      Possible values: true, false

    • -q, --quiet \u2014 Do not print the list of remaining conflicts (if any) after resolving a conflict

      Possible values: true, false

    • --tool <NAME> \u2014 Specify 3-way merge tool to be used

    "},{"location":"cli-reference/#jj-restore","title":"jj restore","text":"

    Restore paths from another revision

    That means that the paths get the same content in the destination (--to) as they had in the source (--from). This is typically used for undoing changes to some paths in the working copy (jj restore <paths>).

    If only one of --from or --to is specified, the other one defaults to the working copy.

    When neither --from nor --to is specified, the command restores into the working copy from its parent(s). jj restore without arguments is similar to jj abandon, except that it leaves an empty revision with its description and other metadata preserved.

    See jj diffedit if you'd like to restore portions of files rather than entire files.

    Usage: jj restore [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_36","title":"Arguments:","text":"
    • <PATHS> \u2014 Restore only these paths (instead of all paths)
    "},{"location":"cli-reference/#options_38","title":"Options:","text":"
    • --from <FROM> \u2014 Revision to restore from (source)
    • --to <TO> \u2014 Revision to restore into (destination)
    • -c, --changes-in <REVISION> \u2014 Undo the changes in a revision as compared to the merge of its parents
    • -r, --revision <REVISION> \u2014 Prints an error. DO NOT USE
    "},{"location":"cli-reference/#jj-root","title":"jj root","text":"

    Show the current workspace root directory

    Usage: jj root

    "},{"location":"cli-reference/#jj-show","title":"jj show","text":"

    Show commit description and changes in a revision

    Usage: jj show [OPTIONS] [REVISION]

    "},{"location":"cli-reference/#arguments_37","title":"Arguments:","text":"
    • <REVISION> \u2014 Show changes in this revision, compared to its parent(s)

      Default value: @

    "},{"location":"cli-reference/#options_39","title":"Options:","text":"
    • -r \u2014 Ignored (but lets you pass -r for consistency with other commands)

      Possible values: true, false

    • -T, --template <TEMPLATE> \u2014 Render a revision using the given template

    • -s, --summary \u2014 For each path, show only whether it was modified, added, or deleted

      Possible values: true, false

    • --stat \u2014 Show a histogram of the changes

      Possible values: true, false

    • --types \u2014 For each path, show only its type before and after

      Possible values: true, false

    • --git \u2014 Show a Git-format diff

      Possible values: true, false

    • --color-words \u2014 Show a word-level diff with changes indicated only by color

      Possible values: true, false

    • --tool <TOOL> \u2014 Generate diff by external command

    • --context <CONTEXT> \u2014 Number of lines of context to show
    "},{"location":"cli-reference/#jj-sparse","title":"jj sparse","text":"

    Manage which paths from the working-copy commit are present in the working copy

    Usage: jj sparse <COMMAND>

    "},{"location":"cli-reference/#subcommands_6","title":"Subcommands:","text":"
    • list \u2014 List the patterns that are currently present in the working copy
    • set \u2014 Update the patterns that are present in the working copy
    • reset \u2014 Reset the patterns to include all files in the working copy
    • edit \u2014 Start an editor to update the patterns that are present in the working copy
    "},{"location":"cli-reference/#jj-sparse-list","title":"jj sparse list","text":"

    List the patterns that are currently present in the working copy

    By default, a newly cloned or initialized repo will have have a pattern matching all files from the repo root. That pattern is rendered as . (a single period).

    Usage: jj sparse list

    "},{"location":"cli-reference/#jj-sparse-set","title":"jj sparse set","text":"

    Update the patterns that are present in the working copy

    For example, if all you need is the README.md and the lib/ directory, use jj sparse set --clear --add README.md --add lib. If you no longer need the lib directory, use jj sparse set --remove lib.

    Usage: jj sparse set [OPTIONS]

    "},{"location":"cli-reference/#options_40","title":"Options:","text":"
    • --add <ADD> \u2014 Patterns to add to the working copy
    • --remove <REMOVE> \u2014 Patterns to remove from the working copy
    • --clear \u2014 Include no files in the working copy (combine with --add)

      Possible values: true, false

    "},{"location":"cli-reference/#jj-sparse-reset","title":"jj sparse reset","text":"

    Reset the patterns to include all files in the working copy

    Usage: jj sparse reset

    "},{"location":"cli-reference/#jj-sparse-edit","title":"jj sparse edit","text":"

    Start an editor to update the patterns that are present in the working copy

    Usage: jj sparse edit

    "},{"location":"cli-reference/#jj-split","title":"jj split","text":"

    Split a revision in two

    Starts a diff editor (meld by default) on the changes in the revision. Edit the right side of the diff until it has the content you want in the first revision. Once you close the editor, your edited content will replace the previous revision. The remaining changes will be put in a new revision on top.

    If the change you split had a description, you will be asked to enter a change description for each commit. If the change did not have a description, the second part will not get a description, and you will be asked for a description only for the first part.

    Usage: jj split [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_38","title":"Arguments:","text":"
    • <PATHS> \u2014 Put these paths in the first commit
    "},{"location":"cli-reference/#options_41","title":"Options:","text":"
    • -i, --interactive \u2014 Interactively choose which parts to split. This is the default if no paths are provided

      Possible values: true, false

    • --tool <NAME> \u2014 Specify diff editor to be used (implies --interactive)

    • -r, --revision <REVISION> \u2014 The revision to split

      Default value: @

    "},{"location":"cli-reference/#jj-squash","title":"jj squash","text":"

    Move changes from a revision into another revision

    With the -r option, moves the changes from the specified revision to the parent revision. Fails if there are several parent revisions (i.e., the given revision is a merge).

    With the --from and/or --into options, moves changes from/to the given revisions. If either is left out, it defaults to the working-copy commit. For example, jj squash --into @-- moves changes from the working-copy commit to the grandparent.

    If, after moving changes out, the source revision is empty compared to its parent(s), it will be abandoned. Without --interactive, the source revision will always be empty.

    If the source became empty and both the source and destination had a non-empty description, you will be asked for the combined description. If either was empty, then the other one will be used.

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj squash [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_39","title":"Arguments:","text":"
    • <PATHS> \u2014 Move only changes to these paths (instead of all paths)
    "},{"location":"cli-reference/#options_42","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 Revision to squash into its parent (default: @)
    • --from <FROM> \u2014 Revision to squash from (default: @)
    • --into <INTO> \u2014 Revision to squash into (default: @)
    • -m, --message <MESSAGE> \u2014 The description to use for squashed revision (don't open editor)
    • -i, --interactive \u2014 Interactively choose which parts to squash

      Possible values: true, false

    • --tool <NAME> \u2014 Specify diff editor to be used (implies --interactive)

    "},{"location":"cli-reference/#jj-status","title":"jj status","text":"

    Show high-level repo status

    This includes:

    • The working copy commit and its (first) parent, and a summary of the changes between them

    • Conflicted branches (see https://github.com/martinvonz/jj/blob/main/docs/branches.md)

    Usage: jj status

    "},{"location":"cli-reference/#jj-tag","title":"jj tag","text":"

    Manage tags

    Usage: jj tag <COMMAND>

    "},{"location":"cli-reference/#subcommands_7","title":"Subcommands:","text":"
    • list \u2014 List tags
    "},{"location":"cli-reference/#jj-tag-list","title":"jj tag list","text":"

    List tags

    Usage: jj tag list [NAMES]...

    "},{"location":"cli-reference/#arguments_40","title":"Arguments:","text":"
    • <NAMES> \u2014 Show tags whose local name matches
    "},{"location":"cli-reference/#jj-util","title":"jj util","text":"

    Infrequently used commands such as for generating shell completions

    Usage: jj util <COMMAND>

    "},{"location":"cli-reference/#subcommands_8","title":"Subcommands:","text":"
    • completion \u2014 Print a command-line-completion script
    • gc \u2014 Run backend-dependent garbage collection
    • mangen \u2014 Print a ROFF (manpage)
    • markdown-help \u2014 Print the CLI help for all subcommands in Markdown
    • config-schema \u2014 Print the JSON schema for the jj TOML config format
    "},{"location":"cli-reference/#jj-util-completion","title":"jj util completion","text":"

    Print a command-line-completion script

    Apply it by running one of these:

    • bash: source <(jj util completion bash)
    • fish: jj util completion fish | source
    • nushell:
      jj util completion nushell | save \"completions-jj.nu\"\nuse \"completions-jj.nu\" *  # Or `source \"completions-jj.nu\"`\n
    • zsh:
      autoload -U compinit\ncompinit\nsource <(jj util completion zsh)\n

    Usage: jj util completion [SHELL]

    "},{"location":"cli-reference/#arguments_41","title":"Arguments:","text":"
    • <SHELL>

      Possible values: bash, elvish, fish, nushell, power-shell, zsh

    "},{"location":"cli-reference/#options_43","title":"Options:","text":"
    • --bash \u2014 Deprecated. Use the SHELL positional argument instead

      Possible values: true, false

    • --fish \u2014 Deprecated. Use the SHELL positional argument instead

      Possible values: true, false

    • --zsh \u2014 Deprecated. Use the SHELL positional argument instead

      Possible values: true, false

    "},{"location":"cli-reference/#jj-util-gc","title":"jj util gc","text":"

    Run backend-dependent garbage collection

    Usage: jj util gc [OPTIONS]

    "},{"location":"cli-reference/#options_44","title":"Options:","text":"
    • --expire <EXPIRE> \u2014 Time threshold
    "},{"location":"cli-reference/#jj-util-mangen","title":"jj util mangen","text":"

    Print a ROFF (manpage)

    Usage: jj util mangen

    "},{"location":"cli-reference/#jj-util-markdown-help","title":"jj util markdown-help","text":"

    Print the CLI help for all subcommands in Markdown

    Usage: jj util markdown-help

    "},{"location":"cli-reference/#jj-util-config-schema","title":"jj util config-schema","text":"

    Print the JSON schema for the jj TOML config format

    Usage: jj util config-schema

    "},{"location":"cli-reference/#jj-undo","title":"jj undo","text":"

    Undo an operation (shortcut for jj op undo)

    Usage: jj undo [OPTIONS] [OPERATION]

    "},{"location":"cli-reference/#arguments_42","title":"Arguments:","text":"
    • <OPERATION> \u2014 The operation to undo

      Default value: @

    "},{"location":"cli-reference/#options_45","title":"Options:","text":"
    • --what <WHAT> \u2014 What portions of the local state to restore (can be repeated)

      Default values: repo, remote-tracking

      Possible values:

      • repo: The jj repo state and local branches
      • remote-tracking: The remote-tracking branches. Do not restore these if you'd like to push after the undo
    "},{"location":"cli-reference/#jj-unsquash","title":"jj unsquash","text":"

    Move changes from a revision's parent into the revision

    After moving the changes out of the parent, the child revision will have the same content state as before. If moving the change out of the parent change made it empty compared to its parent, it will be abandoned. Without --interactive, the parent change will always become empty.

    If the source became empty and both the source and destination had a non-empty description, you will be asked for the combined description. If either was empty, then the other one will be used.

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj unsquash [OPTIONS]

    "},{"location":"cli-reference/#options_46","title":"Options:","text":"
    • -r, --revision <REVISION>

      Default value: @

    • -i, --interactive \u2014 Interactively choose which parts to unsquash

      Possible values: true, false

    • --tool <NAME> \u2014 Specify diff editor to be used (implies --interactive)

    "},{"location":"cli-reference/#jj-untrack","title":"jj untrack","text":"

    Stop tracking specified paths in the working copy

    Usage: jj untrack <PATHS>...

    "},{"location":"cli-reference/#arguments_43","title":"Arguments:","text":"
    • <PATHS> \u2014 Paths to untrack. They must already be ignored
    "},{"location":"cli-reference/#jj-version","title":"jj version","text":"

    Display version information

    Usage: jj version

    "},{"location":"cli-reference/#jj-workspace","title":"jj workspace","text":"

    Commands for working with workspaces

    Workspaces let you add additional working copies attached to the same repo. A common use case is so you can run a slow build or test in one workspace while you're continuing to write code in another workspace.

    Each workspace has its own working-copy commit. When you have more than one workspace attached to a repo, they are indicated by @<workspace name> in jj log.

    Each workspace also has own sparse patterns.

    Usage: jj workspace <COMMAND>

    "},{"location":"cli-reference/#subcommands_9","title":"Subcommands:","text":"
    • add \u2014 Add a workspace
    • forget \u2014 Stop tracking a workspace's working-copy commit in the repo
    • list \u2014 List workspaces
    • root \u2014 Show the current workspace root directory
    • update-stale \u2014 Update a workspace that has become stale
    "},{"location":"cli-reference/#jj-workspace-add","title":"jj workspace add","text":"

    Add a workspace

    Sparse patterns will be copied over from the current workspace.

    Usage: jj workspace add [OPTIONS] <DESTINATION>

    "},{"location":"cli-reference/#arguments_44","title":"Arguments:","text":"
    • <DESTINATION> \u2014 Where to create the new workspace
    "},{"location":"cli-reference/#options_47","title":"Options:","text":"
    • --name <NAME> \u2014 A name for the workspace
    • -r, --revision <REVISION> \u2014 A list of parent revisions for the working-copy commit of the newly created workspace. You may specify nothing, or any number of parents
    "},{"location":"cli-reference/#jj-workspace-forget","title":"jj workspace forget","text":"

    Stop tracking a workspace's working-copy commit in the repo

    The workspace will not be touched on disk. It can be deleted from disk before or after running this command.

    Usage: jj workspace forget [WORKSPACES]...

    "},{"location":"cli-reference/#arguments_45","title":"Arguments:","text":"
    • <WORKSPACES> \u2014 Names of the workspaces to forget. By default, forgets only the current workspace
    "},{"location":"cli-reference/#jj-workspace-list","title":"jj workspace list","text":"

    List workspaces

    Usage: jj workspace list

    "},{"location":"cli-reference/#jj-workspace-root","title":"jj workspace root","text":"

    Show the current workspace root directory

    Usage: jj workspace root

    "},{"location":"cli-reference/#jj-workspace-update-stale","title":"jj workspace update-stale","text":"

    Update a workspace that has become stale

    For information about stale working copies, see https://github.com/martinvonz/jj/blob/main/docs/working-copy.md.

    Usage: jj workspace update-stale

    This document was generated automatically by clap-markdown.

    "},{"location":"code-of-conduct/","title":"Contributor Covenant Code of Conduct","text":""},{"location":"code-of-conduct/#our-pledge","title":"Our Pledge","text":"

    We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.

    We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

    "},{"location":"code-of-conduct/#our-standards","title":"Our Standards","text":"

    Examples of behavior that contributes to a positive environment for our community include:

    • Demonstrating empathy and kindness toward other people
    • Being respectful of differing opinions, viewpoints, and experiences
    • Giving and gracefully accepting constructive feedback
    • Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
    • Focusing on what is best not just for us as individuals, but for the overall community

    Examples of unacceptable behavior include:

    • The use of sexualized language or imagery, and sexual attention or advances of any kind
    • Trolling, insulting or derogatory comments, and personal or political attacks
    • Public or private harassment
    • Publishing others' private information, such as a physical or email address, without their explicit permission
    • Other conduct which could reasonably be considered inappropriate in a professional setting
    "},{"location":"code-of-conduct/#enforcement-responsibilities","title":"Enforcement Responsibilities","text":"

    Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

    Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

    "},{"location":"code-of-conduct/#scope","title":"Scope","text":"

    This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

    "},{"location":"code-of-conduct/#enforcement","title":"Enforcement","text":"

    Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at two or more of jaraco@jaraco.com, avamsi07@gmail.com, me@waleedkhan.name, and opensource@google.com. All complaints will be reviewed and investigated promptly and fairly.

    All community leaders are obligated to respect the privacy and security of the reporter of any incident.

    "},{"location":"code-of-conduct/#enforcement-guidelines","title":"Enforcement Guidelines","text":"

    Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

    "},{"location":"code-of-conduct/#1-correction","title":"1. Correction","text":"

    Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

    Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

    "},{"location":"code-of-conduct/#2-warning","title":"2. Warning","text":"

    Community Impact: A violation through a single incident or series of actions.

    Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

    "},{"location":"code-of-conduct/#3-temporary-ban","title":"3. Temporary Ban","text":"

    Community Impact: A serious violation of community standards, including sustained inappropriate behavior.

    Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

    "},{"location":"code-of-conduct/#4-permanent-ban","title":"4. Permanent Ban","text":"

    Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

    Consequence: A permanent ban from any sort of public interaction within the community.

    "},{"location":"code-of-conduct/#attribution","title":"Attribution","text":"

    This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.

    Community Impact Guidelines were inspired by Mozilla's code of conduct enforcement ladder.

    For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

    "},{"location":"config/","title":"Configuration","text":"

    These are the config settings available to jj/Jujutsu.

    "},{"location":"config/#config-files-and-toml","title":"Config files and TOML","text":"

    jj loads several types of config settings:

    • The built-in settings. These cannot be edited. They can be viewed in the cli/src/config/ directory in jj's source repo.

    • The user settings. These can be edited with jj config edit --user. User settings are located in the user config file, which can be found with jj config path --user.

    • The repo settings. These can be edited with jj config edit --repo and are located in .jj/repo/config.toml.

    • Settings specified in the command-line.

    These are listed in the order they are loaded; the settings from earlier items in the list are overridden by the settings from later items if they disagree. Every type of config except for the built-in settings is optional.

    See the TOML site and the syntax guide for a detailed description of the syntax. We cover some of the basics below.

    The first thing to remember is that the value of a setting (the part to the right of the = sign) should be surrounded in quotes if it's a string.

    "},{"location":"config/#dotted-style-and-headings","title":"Dotted style and headings","text":"

    In TOML, anything under a heading can be dotted instead. For example, user.name = \"YOUR NAME\" is equivalent to:

    [user]\nname = \"YOUR NAME\"\n

    For future reference, here are a couple of more complicated examples,

    # Dotted style\ntemplate-aliases.\"format_short_id(id)\" = \"id.shortest(12)\"\ncolors.\"commit_id prefix\".bold = true\n\n# is equivalent to:\n[template-aliases]\n\"format_short_id(id)\" = \"id.shortest(12)\"\n\n[colors]\n\"commit_id prefix\" = { bold = true }\n

    Jujutsu favors the dotted style in these instructions, if only because it's easier to write down in an unconfusing way. If you are confident with TOML then use whichever suits you in your config. If you mix dotted keys and headings, put the dotted keys before the first heading.

    That's probably enough TOML to keep you out of trouble but the syntax guide is very short if you ever need to check.

    "},{"location":"config/#user-settings","title":"User settings","text":"
    user.name = \"YOUR NAME\"\nuser.email = \"YOUR_EMAIL@example.com\"\n

    Don't forget to change these to your own details!

    "},{"location":"config/#ui-settings","title":"UI settings","text":""},{"location":"config/#colorizing-output","title":"Colorizing output","text":"

    Possible values are always, never and auto (default: auto). auto will use color only when writing to a terminal.

    This setting overrides the NO_COLOR environment variable (if set).

    ui.color = \"never\" # Turn off color\n
    "},{"location":"config/#custom-colors-and-styles","title":"Custom colors and styles","text":"

    You can customize the colors used for various elements of the UI. For example:

    colors.commit_id = \"green\"\n

    The following colors are available:

    • black
    • red
    • green
    • yellow
    • blue
    • magenta
    • cyan
    • white
    • default

    All of them but \"default\" come in a bright version too, e.g. \"bright red\". The \"default\" color can be used to override a color defined by a parent style (explained below).

    You can also use a 6-digit hex code for more control over the exact color used:

    colors.change_id = \"#ff1525\"\n

    If you use a string value for a color, as in the examples above, it will be used for the foreground color. You can also set the background color, or make the text bold or underlined. For that, you need to use a table:

    colors.commit_id = { fg = \"green\", bg = \"#ff1525\", bold = true, underline = true }\n

    The key names are called \"labels\". The above used commit_id as label. You can also create rules combining multiple labels. The rules work a bit like CSS selectors. For example, if you want to color commit IDs green in general but make the commit ID of the working-copy commit also be underlined, you can do this:

    colors.commit_id = \"green\"\ncolors.\"working_copy commit_id\" = { underline = true }\n

    Parts of the style that are not overridden - such as the foreground color in the example above - are inherited from the parent style.

    Which elements can be colored is not yet documented, but see the default color configuration for some examples of what's possible.

    "},{"location":"config/#default-command","title":"Default command","text":"

    When jj is run with no explicit subcommand, the value of the ui.default-command setting will be used instead. Possible values are any valid subcommand name, subcommand alias, or user-defined alias (defaults to \"log\").

    ui.default-command = \"log\"\n
    "},{"location":"config/#default-description","title":"Default description","text":"

    The value of the ui.default-description setting will be used to prepopulate the editor when describing changes with an empty description. This could be a useful reminder to fill in things like BUG=, TESTED= etc.

    ui.default-description = \"\\n\\nTESTED=TODO\"\n
    "},{"location":"config/#diff-format","title":"Diff format","text":"
    # Possible values: \"color-words\" (default), \"git\", \"summary\"\nui.diff.format = \"git\"\n
    "},{"location":"config/#generating-diffs-by-external-command","title":"Generating diffs by external command","text":"

    If ui.diff.tool is set, the specified diff command will be called instead of the internal diff function.

    [ui]\n# Use Difftastic by default\ndiff.tool = [\"difft\", \"--color=always\", \"$left\", \"$right\"]\n# Use tool named \"<name>\" (see below)\ndiff.tool = \"<name>\"\n

    The external diff tool can also be enabled by diff --tool <name> argument. For the tool named <name>, command arguments can be configured as follows.

    [merge-tools.<name>]\n# program = \"<name>\"  # Defaults to the name of the tool if not specified\ndiff-args = [\"--color=always\", \"$left\", \"$right\"]\n
    • $left and $right are replaced with the paths to the left and right directories to diff respectively.
    "},{"location":"config/#set-of-immutable-commits","title":"Set of immutable commits","text":"

    You can configure the set of immutable commits via revset-aliases.\"immutable_heads()\". The default set of immutable heads is trunk() | tags(). For example, to prevent rewriting commits on main@origin and commits authored by other users:

    # The `main.. &` bit is an optimization to scan for non-`mine()` commits only\n# among commits that are not in `main`.\nrevset-aliases.\"immutable_heads()\" = \"main@origin | (main@origin.. & ~mine())\"\n

    Ancestors of the configured set are also immutable. The root commit is always immutable even if the set is empty.

    "},{"location":"config/#default-revisions-to-log","title":"Default revisions to log","text":"

    You can configure the revisions jj log without -r should show.

    # Show commits that are not in `main@origin`\nrevsets.log = \"main@origin..\"\n
    "},{"location":"config/#graph-style","title":"Graph style","text":"
    # Possible values: \"curved\" (default), \"square\", \"ascii\", \"ascii-large\"\nui.graph.style = \"square\"\n
    "},{"location":"config/#node-style","title":"Node style","text":"

    The symbols used to represent commits or operations can be customized via templates.

    * templates.log_node for commits (with Option<Commit> keywords) * templates.op_log_node for operations (with Operation keywords)

    For example:

    [templates]\nlog_node = '''\ncoalesce(\n  if(!self, \"\ud83e\udf80\"),\n  if(current_working_copy, \"@\"),\n  if(root, \"\u2534\"),\n  if(immutable, \"\u25cf\", \"\u25cb\"),\n)\n'''\nop_log_node = 'if(current_operation, \"@\", \"\u25cb\")'\n

    "},{"location":"config/#wrap-log-content","title":"Wrap log content","text":"

    If enabled, log/obslog/op log content will be wrapped based on the terminal width.

    ui.log-word-wrap = true\n
    "},{"location":"config/#display-of-commit-and-change-ids","title":"Display of commit and change ids","text":"

    Can be customized by the format_short_id() template alias.

    [template-aliases]\n# Highlight unique prefix and show at least 12 characters (default)\n'format_short_id(id)' = 'id.shortest(12)'\n# Just the shortest possible unique prefix\n'format_short_id(id)' = 'id.shortest()'\n# Show unique prefix and the rest surrounded by brackets\n'format_short_id(id)' = 'id.shortest(12).prefix() ++ \"[\" ++ id.shortest(12).rest() ++ \"]\"'\n# Always show 12 characters\n'format_short_id(id)' = 'id.short(12)'\n

    To customize these separately, use the format_short_commit_id() and format_short_change_id() aliases:

    [template-aliases]\n# Uppercase change ids. `jj` treats change and commit ids as case-insensitive.\n'format_short_change_id(id)' = 'format_short_id(id).upper()'\n

    To get shorter prefixes for certain revisions, set revsets.short-prefixes:

    # Prioritize the current branch\nrevsets.short-prefixes = \"(main..@)::\"\n
    "},{"location":"config/#relative-timestamps","title":"Relative timestamps","text":"

    Can be customized by the format_timestamp() template alias.

    [template-aliases]\n# Full timestamp in ISO 8601 format\n'format_timestamp(timestamp)' = 'timestamp'\n# Relative timestamp rendered as \"x days/hours/seconds ago\"\n'format_timestamp(timestamp)' = 'timestamp.ago()'\n

    jj op log defaults to relative timestamps. To use absolute timestamps, you will need to modify the format_time_range() template alias.

    [template-aliases]\n'format_time_range(time_range)' = 'time_range.start() ++ \" - \" ++ time_range.end()'\n
    "},{"location":"config/#author-format","title":"Author format","text":"

    Can be customized by the format_short_signature() template alias.

    [template-aliases]\n# Full email address (default)\n'format_short_signature(signature)' = 'signature.email()'\n# Both name and email address\n'format_short_signature(signature)' = 'signature'\n# Username part of the email address\n'format_short_signature(signature)' = 'signature.username()'\n
    "},{"location":"config/#pager","title":"Pager","text":"

    The default pager is can be set via ui.pager or the PAGER environment variable. The priority is as follows (environment variables are marked with a $):

    ui.pager > $PAGER

    less -FRX is the default pager in the absence of any other setting, except on Windows where it is :builtin.

    The special value :builtin enables usage of the integrated pager. It is likely if you are using a standard Linux distro, your system has $PAGER set already and that will be preferred over the built-in. To use the built-in:

    jj config set --user ui.pager :builtin\n

    It is possible the default will change to :builtin for all platforms in the future.

    Additionally, paging behavior can be toggled via ui.paginate like so:

    # Enable pagination for commands that support it (default)\nui.paginate = \"auto\"\n# Disable all pagination, equivalent to using --no-pager\nui.paginate = \"never\"\n
    "},{"location":"config/#processing-contents-to-be-paged","title":"Processing contents to be paged","text":"

    If you'd like to pass the output through a formatter e.g. diff-so-fancy before piping it through a pager you must do it using a subshell as, unlike git or hg, the command will be executed directly. For example:

    ui.pager = [\"sh\", \"-c\", \"diff-so-fancy | less -RFX\"]\n
    "},{"location":"config/#aliases","title":"Aliases","text":"

    You can define aliases for commands, including their arguments. For example:

    # `jj l` shows commits on the working-copy commit's (anonymous) branch\n# compared to the `main` branch\naliases.l = [\"log\", \"-r\", \"(main..@):: | (main..@)-\"]\n
    "},{"location":"config/#editor","title":"Editor","text":"

    The default editor is set via ui.editor, though there are several places to set it. The priority is as follows (environment variables are marked with a $):

    $JJ_EDITOR > ui.editor > $VISUAL > $EDITOR

    Pico is the default editor (Notepad on Windows) in the absence of any other setting, but you could set it explicitly too.

    ui.editor = \"pico\"\n

    To use NeoVim instead:

    ui.editor = \"nvim\"\n

    For GUI editors you possibly need to use a -w or --wait. Some examples:

    ui.editor = \"code -w\"       # VS Code\nui.editor = \"bbedit -w\"     # BBEdit\nui.editor = \"subl -n -w\"    # Sublime Text\nui.editor = \"mate -w\"       # TextMate\nui.editor = [\"C:/Program Files/Notepad++/notepad++.exe\",\n    \"-multiInst\", \"-notabbar\", \"-nosession\", \"-noPlugin\"] # Notepad++\nui.editor = \"idea --temp-project --wait\"   #IntelliJ\n

    Obviously, you would only set one line, don't copy them all in!

    "},{"location":"config/#editing-diffs","title":"Editing diffs","text":"

    The ui.diff-editor setting affects the tool used for editing diffs (e.g. jj split, jj squash -i). The default is the special value :builtin, which launches a built-in TUI tool (known as scm-diff-editor) to edit the diff in your terminal.

    jj makes the following substitutions:

    • $left and $right are replaced with the paths to the left and right directories to diff respectively.

    If no arguments are specified, [\"$left\", \"$right\"] are set by default.

    For example:

    # Use merge-tools.kdiff3.edit-args\nui.diff-editor = \"kdiff3\"\n# Specify edit-args inline\nui.diff-editor = [\"kdiff3\", \"--merge\", \"$left\", \"$right\"]\n

    If ui.diff-editor consists of a single word, e.g. \"kdiff3\", the arguments will be read from the following config keys.

    # merge-tools.kdiff3.program = \"kdiff3\"      # Defaults to the name of the tool if not specified\nmerge-tools.kdiff3.edit-args = [\n    \"--merge\", \"--cs\", \"CreateBakFiles=0\", \"$left\", \"$right\"]\n
    "},{"location":"config/#experimental-3-pane-diff-editing","title":"Experimental 3-pane diff editing","text":"

    The special \"meld-3\" diff editor sets up Meld to show 3 panes: the sides of the diff on the left and right, and an editing pane in the middle. This allow you to see both sides of the original diff while editing. If you use ui.diff-editor = \"meld-3\", note that you can still get the 2-pane Meld view using jj diff --tool meld.

    To configure other diff editors, you can include $output together with $left and $right in merge-tools.TOOL.edit-args. jj will replace $output with the directory where the diff editor will be expected to put the result of the user's edits. Initially, the contents of $output will be the same as the contents of $right.

    "},{"location":"config/#jj-instructions","title":"JJ-INSTRUCTIONS","text":"

    When editing a diff, jj will include a synthetic file called JJ-INSTRUCTIONS in the diff with instructions on how to edit the diff. Any changes you make to this file will be ignored. To suppress the creation of this file, set ui.diff-instructions = false.

    "},{"location":"config/#using-vim-as-a-diff-editor","title":"Using Vim as a diff editor","text":"

    Using ui.diff-editor = \"vimdiff\" is possible but not recommended. For a better experience, you can follow instructions from the Wiki to configure the DirDiff Vim plugin and/or the vimtabdiff Python script.

    "},{"location":"config/#3-way-merge-tools-for-conflict-resolution","title":"3-way merge tools for conflict resolution","text":"

    The ui.merge-editor key specifies the tool used for three-way merge tools by jj resolve. For example:

    # Use merge-tools.meld.merge-args\nui.merge-editor = \"meld\"  # Or \"vscode\" or \"kdiff3\" or \"vimdiff\"\n# Specify merge-args inline\nui.merge-editor = [\"meld\", \"$left\", \"$base\", \"$right\", \"-o\", \"$output\"]\n

    The \"vscode\", \"meld\", \"kdiff3\", and \"vimdiff\" tools can be used out of the box, as long as they are installed.

    Using VS Code as a merge tool works well with VS Code's Remote Development functionality, as long as jj is called from VS Code's terminal.

    "},{"location":"config/#setting-up-a-custom-merge-tool","title":"Setting up a custom merge tool","text":"

    To use a different tool named TOOL, the arguments to pass to the tool MUST be specified either inline or in the merge-tools.TOOL.merge-args key. As an example of how to set this key and other tool configuration options, here is the out-of-the-box configuration of the three default tools. (There is no need to copy it to your config file verbatim, but you are welcome to customize it.)

    # merge-tools.kdiff3.program  = \"kdiff3\"     # Defaults to the name of the tool if not specified\nmerge-tools.kdiff3.merge-args = [\"$base\", \"$left\", \"$right\", \"-o\", \"$output\", \"--auto\"]\nmerge-tools.meld.merge-args = [\"$left\", \"$base\", \"$right\", \"-o\", \"$output\", \"--auto-merge\"]\n\nmerge-tools.vimdiff.merge-args = [\"-f\", \"-d\", \"$output\", \"-M\",\n    \"$left\", \"$base\", \"$right\",\n    \"-c\", \"wincmd J\", \"-c\", \"set modifiable\",\n    \"-c\", \"set write\"]\nmerge-tools.vimdiff.program = \"vim\"\nmerge-tools.vimdiff.merge-tool-edits-conflict-markers = true    # See below for an explanation\n

    jj makes the following substitutions:

    • $output (REQUIRED) is replaced with the name of the file that the merge tool should output. jj will read this file after the merge tool exits.

    • $left and $right are replaced with the paths to two files containing the content of each side of the conflict.

    • $base is replaced with the path to a file containing the contents of the conflicted file in the last common ancestor of the two sides of the conflict.

    "},{"location":"config/#editing-conflict-markers-with-a-tool-or-a-text-editor","title":"Editing conflict markers with a tool or a text editor","text":"

    By default, the merge tool starts with an empty output file. If the tool puts anything into the output file, and exits with the 0 exit code, jj assumes that the conflict is fully resolved. This is appropriate for most graphical merge tools.

    Some tools (e.g. vimdiff) can present a multi-way diff but don't resolve conflict themselves. When using such tools, jj can help you by populating the output file with conflict markers before starting the merge tool (instead of leaving the output file empty and letting the merge tool fill it in). To do that, set the merge-tools.vimdiff.merge-tool-edits-conflict-markers = true option.

    With this option set, if the output file still contains conflict markers after the conflict is done, jj assumes that the conflict was only partially resolved and parses the conflict markers to get the new state of the conflict. The conflict is considered fully resolved when there are no conflict markers left.

    "},{"location":"config/#commit-signing","title":"Commit Signing","text":"

    jj can be configured to sign and verify the commits it creates using either GnuPG or SSH signing keys.

    To do this you need to configure a signing backend.

    "},{"location":"config/#gnupg-signing","title":"GnuPG Signing","text":"
    [signing]\nsign-all = true\nbackend = \"gpg\"\nkey = \"4ED556E9729E000F\"\n## You can set `key` to anything accepted by `gpg -u`\n# key = \"signing@example.com\"\n

    By default the gpg backend will look for a gpg binary on your path. If you want to change the program used or specify a path to gpg explicitly you can set:

    signing.backends.gpg.program = \"gpg2\"\n

    Also by default the gpg backend will ignore key expiry when verifying commit signatures. To consider expired keys as invalid you can set:

    signing.backends.gpg.allow-expired-keys = false\n
    "},{"location":"config/#ssh-signing","title":"SSH Signing","text":"
    [signing]\nsign-all = true\nbackend = \"ssh\"\nkey = \"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGj+J6N6SO+4P8dOZqfR1oiay2yxhhHnagH52avUqw5h\"\n## You can also use a path instead of embedding the key\n# key = \"/home/me/.ssh/id_for_signing.pub\"\n

    By default the ssh backend will look for a ssh-keygen binary on your path. If you want to change the program used or specify a path to ssh-keygen explicitly you can set:

    signing.backends.ssh.program = \"/path/to/ssh-keygen\"\n

    When verifying commit signatures the ssh backend needs to be provided with an allowed-signers file containing the public keys of authors whose signatures you want to be able to verify.

    You can find the format for this file in the ssh-keygen man page. This can be provided as follows:

    signing.backends.ssh.allowed-signers = \"/path/to/allowed-signers\"\n
    "},{"location":"config/#git-settings","title":"Git settings","text":""},{"location":"config/#default-remotes-for-jj-git-fetch-and-jj-git-push","title":"Default remotes for jj git fetch and jj git push","text":"

    By default, if a single remote exists it is used for jj git fetch and jj git push; however if multiple remotes exist, the default remote is assumed to be named \"origin\", just like in Git. Sometimes this is undesirable, e.g. when you want to fetch from a different remote than you push to, such as a GitHub fork.

    To change this behavior, you can modify the repository configuration variable git.fetch, which can be a single remote, or a list of remotes to fetch from multiple places:

    jj config set --repo git.fetch \"upstream\"\njj config set --repo git.fetch '[\"origin\", \"upstream\"]'\n

    Similarly, you can also set the variable git.push to cause jj git push to push to a different remote:

    jj config set --repo git.push \"github\"\n

    Note that unlike git.fetch, git.push can currently only be a single remote. This is not a hard limitation, and could be changed in the future if there is demand.

    "},{"location":"config/#automatic-local-branch-creation","title":"Automatic local branch creation","text":"

    When jj imports a new remote-tracking branch from Git, it can also create a local branch with the same name. This feature is disabled by default because it may be undesirable in some repositories, e.g.:

    • There is a remote with a lot of historical branches that you don't want to be exported to the co-located Git repo.
    • There are multiple remotes with conflicting views of that branch, resulting in an unhelpful conflicted state.

    You can enable this behavior by setting git.auto-local-branch like so,

    git.auto-local-branch = true\n

    This setting is applied only to new remote branches. Existing remote branches can be tracked individually by using jj branch track/untrack commands.

    # import feature1 branch and start tracking it\njj branch track feature1@origin\n# delete local gh-pages branch and stop tracking it\njj branch delete gh-pages\njj branch untrack gh-pages@upstream\n
    "},{"location":"config/#abandon-commits-that-became-unreachable-in-git","title":"Abandon commits that became unreachable in Git","text":"

    By default, when jj imports refs from Git, it will look for commits that used to be reachable but no longer are reachable. Those commits will then be abandoned, and any descendant commits will be rebased off of them (as usual when commits are abandoned). You can disable this behavior and instead leave the Git-unreachable commits in your repo by setting:

    git.abandon-unreachable-commits = false\n
    "},{"location":"config/#prefix-for-generated-branches-on-push","title":"Prefix for generated branches on push","text":"

    jj git push --change generates branch names with a prefix of \"push-\" by default. You can pick a different prefix by setting git.push-branch-prefix. For example:

    git.push-branch-prefix = \"martinvonz/push-\"\n
    "},{"location":"config/#filesystem-monitor","title":"Filesystem monitor","text":"

    In large repositories, it may be beneficial to use a \"filesystem monitor\" to track changes to the working copy. This allows jj to take working copy snapshots without having to rescan the entire working copy.

    "},{"location":"config/#watchman","title":"Watchman","text":"

    To configure the Watchman filesystem monitor, set core.fsmonitor = \"watchman\". Ensure that you have installed the Watchman executable on your system.

    Debugging commands are available under jj debug watchman.

    "},{"location":"config/#ways-to-specify-jj-config-details","title":"Ways to specify jj config: details","text":""},{"location":"config/#user-config-file","title":"User config file","text":"

    An easy way to find the user config file is:

    jj config path --user\n

    The rest of this section covers the details of where this file can be located.

    On all platforms, the user's global jj configuration file is located at either ~/.jjconfig.toml (where ~ represents $HOME on Unix-likes, or %USERPROFILE% on Windows) or in a platform-specific directory. The platform-specific location is recommended for better integration with platform services. It is an error for both of these files to exist.

    Platform Value Example Linux $XDG_CONFIG_HOME/jj/config.toml /home/alice/.config/jj/config.toml macOS $HOME/Library/Application Support/jj/config.toml /Users/Alice/Library/Application Support/jj/config.toml Windows {FOLDERID_RoamingAppData}\\jj\\config.toml C:\\Users\\Alice\\AppData\\Roaming\\jj\\config.toml

    The location of the jj config file can also be overridden with the JJ_CONFIG environment variable. If it is not empty, it should contain the path to a TOML file that will be used instead of any configuration file in the default locations. For example,

    env JJ_CONFIG=/dev/null jj log       # Ignores any settings specified in the config file.\n
    "},{"location":"config/#specifying-config-on-the-command-line","title":"Specifying config on the command-line","text":"

    You can use one or more --config-toml options on the command line to specify additional configuration settings. This overrides settings defined in config files or environment variables. For example,

    jj --config-toml='ui.color=\"always\"' --config-toml='ui.diff-editor=\"kdiff3\"' split\n

    Config specified this way must be valid TOML. In particular, string values must be surrounded by quotes. To pass these quotes to jj, most shells require surrounding those quotes with single quotes as shown above.

    In sh-compatible shells, --config-toml can be used to merge entire TOML files with the config specified in .jjconfig.toml:

    jj --config-toml=\"$(cat extra-config.toml)\" log\n
    "},{"location":"conflicts/","title":"First-class conflicts","text":""},{"location":"conflicts/#introduction","title":"Introduction","text":"

    Like Pijul and Darcs but unlike most other VCSs, Jujutsu can record conflicted states in commits. For example, if you rebase a commit and it results in a conflict, the conflict will be recorded in the rebased commit and the rebase operation will succeed. You can then resolve the conflict whenever you want. Conflicted states can be further rebased, merged, or backed out. Note that what's stored in the commit is a logical representation of the conflict, not conflict markers; rebasing a conflict doesn't result in a nested conflict markers (see technical doc for how this works).

    "},{"location":"conflicts/#advantages","title":"Advantages","text":"

    The deeper understanding of conflicts has many advantages:

    • Removes the need for things like git rebase/merge/cherry-pick/etc --continue. Instead, you get a single workflow for resolving conflicts: check out the conflicted commit, resolve conflicts, and amend.
    • Enables the \"auto-rebase\" feature, where descendants of rewritten commits automatically get rewritten. This feature mostly replaces Mercurial's Changeset Evolution.
    • Lets us define the change in a merge commit as being compared to the merged parents. That way, we can rebase merge commits correctly (unlike both Git and Mercurial). That includes conflict resolutions done in the merge commit, addressing a common use case for git rerere. Since the changes in a merge commit are displayed and rebased as expected, evil merges are arguably not as evil anymore.
    • Allows you to postpone conflict resolution until you're ready for it. You can easily keep all your work-in-progress commits rebased onto upstream's head if you like.
    • Criss-cross merges and octopus merges become trivial (implementation-wise); some cases that Git can't currently handle, or that would result in nested conflict markers, can be automatically resolved.
    • Enables collaborative conflict resolution. (This assumes that you can share the conflicts with others, which you probably shouldn't do if some people interact with your project using Git.)

    For information about how conflicts are handled in the working copy, see here.

    "},{"location":"conflicts/#conflict-markers","title":"Conflict markers","text":"

    Conflicts are \"materialized\" using conflict markers in various contexts. For example, when you run jj edit on a commit with a conflict, it will be materialized in the working copy. Conflicts are also materialized when they are part of diff output (e.g. jj show on a commit that introduces or resolves a conflict). Here's an example of how Git can render a conflict using its \"diff3\" style:

      <<<<<<< left\n  apple\n  grapefruit\n  orange\n  ======= base\n  apple\n  grape\n  orange\n  ||||||| right\n  APPLE\n  GRAPE\n  ORANGE\n  >>>>>>>\n

    In this example, the left side changed \"grape\" to \"grapefruit\", and the right side made all lines uppercase. To resolve the conflict, we would presumably keep the right side (the third section) and replace \"GRAPE\" by \"GRAPEFRUIT\". This way of visually finding the changes between the base and one side and then applying them to the other side is a common way of resolving conflicts when using Git's \"diff3\" style.

    Jujutsu helps you by combining the base and one side into a unified diff for you, making it easier to spot the differences to apply to the other side. Here's how that would look for the same example as above:

      <<<<<<<\n  %%%%%%%\n   apple\n  -grape\n  +grapefruit\n   orange\n  +++++++\n  APPLE\n  GRAPE\n  ORANGE\n  >>>>>>>\n

    As in Git, the <<<<<<< and >>>>>>> lines mark the start and end of the conflict. The %%%%%%% line indicates the start of a diff. The +++++++ line indicates the start of a snapshot (not a diff).

    There is another reason for this format (in addition to helping you spot the differences): The format supports more complex conflicts involving more than 3 inputs. Such conflicts can arise when you merge more than 2 commits. They would typically be rendered as a single snapshot (as above) but with more than one unified diffs. The process for resolving them is similar: Manually apply each diff onto the snapshot.

    "},{"location":"contributing/","title":"How to Contribute","text":""},{"location":"contributing/#policies","title":"Policies","text":"

    We'd love to accept your patches and contributions to this project. There are just a few small guidelines you need to follow.

    "},{"location":"contributing/#contributor-license-agreement","title":"Contributor License Agreement","text":"

    Contributions to this project must be accompanied by a Contributor License Agreement. You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project. Head over to https://cla.developers.google.com/ to see your current agreements on file or to sign a new one.

    You generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again.

    "},{"location":"contributing/#code-reviews","title":"Code reviews","text":"

    All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult GitHub Help for more information on using pull requests.

    Unlike many GitHub projects (but like many VCS projects), we care more about the contents of commits than about the contents of PRs. We review each commit separately, and we don't squash-merge the PR (so please manually squash any fixup commits before sending for review).

    Each commit should ideally do one thing. For example, if you need to refactor a function in order to add a new feature cleanly, put the refactoring in one commit and the new feature in a different commit. If the refactoring itself consists of many parts, try to separate out those into separate commits. You can use jj split to do it if you didn't realize ahead of time how it should be split up. Include tests and documentation in the same commit as the code the test and document. The commit message should describe the changes in the commit; the PR description can even be empty, but feel free to include a personal message.

    When you address comments on a PR, don't make the changes in a commit on top (as is typical on GitHub). Instead, please make the changes in the appropriate commit. You can do that by checking out the commit (jj checkout/new <commit>) and then squash in the changes when you're done (jj squash). jj git push will automatically force-push the branch.

    When your first PR has been approved, we typically give you contributor access, so you can address any remaining minor comments and then merge the PR yourself when you're ready. If you realize that some comments require non-trivial changes, please ask your reviewer to take another look.

    To avoid conflicts of interest, please don't merge a PR that has only been approved by someone from the same organization. Similarly, as a reviewer, there is no need to approve your coworkers' PRs, since the author should await an approval from someone else anyway. It is of course still appreciated if you review and comment on their PRs. Also, if the PR seems completely unrelated to your company's interests, do feel free to approve it.

    "},{"location":"contributing/#community-guidelines","title":"Community Guidelines","text":"

    This project follows Google's Open Source Community Guidelines.

    "},{"location":"contributing/#contributing-to-the-documentation","title":"Contributing to the documentation","text":"

    We appreciate bug reports about any problems, however small, lurking in our documentation website or in the jj help <command> docs. If a part of the bug report template does not apply, you can just delete it.

    Before reporting a problem with the documentation website, we'd appreciate it if you could check that the problem still exists in the \"prerelease\" version of the documentation (as opposed to the docs for one of the released versions of jj). You can use the version switcher in the top-left of the website to do so.

    If you are willing to make a PR fixing a documentation problem, even better!

    The documentation website sources are Markdown files located in the docs/ directory. You do not need to know Rust to work with them. See below for instructions on how to preview the HTML docs as you edit the Markdown files. Doing so is optional, but recommended.

    The jj help docs are sourced from the \"docstring\" comments inside the Rust sources, currently from the cli/src/commands directory. Working on them requires setting up a Rust development environment, as described below, and may occasionally require adjusting a test.

    "},{"location":"contributing/#learning-rust","title":"Learning Rust","text":"

    In addition to the Rust Book and the other excellent resources at https://www.rust-lang.org/learn, we recommend the \"Comprehensive Rust\" mini-course for an overview, especially if you are familiar with C++.

    "},{"location":"contributing/#setting-up-a-development-environment","title":"Setting up a development environment","text":"

    To develop jj, the mandatory steps are simply to install Rust (the default installer options are fine), clone the repository, and use cargo build , cargo fmt, cargo clippy --workspace --all-targets, and cargo test --workspace. If you are preparing a PR, there are some additional recommended steps.

    You will probably also want to make the gh-pages branch immutable (and thereby hidden from the default jj log output) by running the following in your repo:

    jj config set --repo \"revset-aliases.immutable_heads()\" \"main@origin | gh-pages@origin\"\n
    "},{"location":"contributing/#summary","title":"Summary","text":"

    One-time setup:

    rustup toolchain add nightly  # wanted for 'rustfmt'\nrustup toolchain add 1.76     # also specified in Cargo.toml\ncargo install cargo-insta\ncargo install cargo-watch\ncargo install cargo-nextest\n

    During development (adapt according to your preference):

    cargo watch --ignore '.jj/**' -s \\\n  'cargo clippy --workspace --all-targets \\\n   && cargo +1.76 check --workspace --all-targets'\ncargo +nightly fmt # Occasionally\ncargo nextest run --workspace # Occasionally\ncargo insta test --workspace --test-runner nextest # Occasionally\n

    WARNING: Build artifacts from debug builds and especially from repeated invocations of cargo test can quickly take up 10s of GB of disk space. Cargo will happily use up your entire hard drive. If this happens, run cargo clean.

    "},{"location":"contributing/#explanation","title":"Explanation","text":"

    These are listed roughly in order of decreasing importance.

    1. Nearly any change to jj's CLI will require writing or updating snapshot tests that use the insta crate. To make this convenient, install the cargo-insta binary. Use cargo insta test --workspace to run tests, and cargo insta review --workspace to update the snapshot tests. The --workspace flag is needed to run the tests on all crates; by default, only the crate in the current directory is tested.

    2. GitHub CI checks require that the code is formatted with the nightly version of rustfmt. To do this on your computer, install the nightly toolchain and use cargo +nightly fmt.

    3. Your code will be rejected if it cannot be compiled with the minimal supported version of Rust (\"MSRV\"). Currently, jj follows a rather casual MSRV policy: \"The current rustc stable version, minus one.\" As of this writing, that version is 1.76.0.

    4. Your code needs to pass cargo clippy. You can also use cargo +nightly clippy if you wish to see more warnings.

    5. You may also want to install and use cargo-watch. In this case, you should exclude .jj. directory from the filesystem watcher, as it gets updated on every jj log.

    6. To run tests more quickly, use cargo nextest run --workspace. To use nextest with insta, use cargo insta test --workspace --test-runner nextest.

      On Linux, you may be able to speed up nextest even further by using the mold linker, as explained below.

    "},{"location":"contributing/#using-mold-for-faster-tests-on-linux","title":"Using mold for faster tests on Linux","text":"

    On a machine with a multi-core CPU, one way to speed up cargo nextest on Linux is to use the multi-threaded mold linker. This linker may help if, currently, your CPU is underused while Rust is linking test binaries. Before proceeding with mold, you can check whether this is an issue worth solving using a system monitoring tool such as htop.

    mold is packaged for many distributions. On Debian, for example, sudo apt install mold should just work.

    A simple way to use mold is via the -run option, e.g.:

    mold -run cargo insta test --workspace --test-runner nextest\n

    There will be no indication that a different linker is used, except for higher CPU usage while linking and, hopefully, faster completion. You can verify that mold was indeed used by running readelf -p .comment target/debug/jj.

    There are also ways of having Rust use mold by default, see the \"How to use\" instructions.

    On recent versions of MacOS, the default linker Rust uses is already multi-threaded. It should use all the CPU cores without any configuration.

    "},{"location":"contributing/#previewing-the-html-documentation","title":"Previewing the HTML documentation","text":"

    The documentation for jj is automatically published to the website at https://martinvonz.github.io/jj/.

    When editing documentation, we'd appreciate it if you checked that the result will look as expected when published to the website.

    "},{"location":"contributing/#setting-up-the-prerequisites","title":"Setting up the prerequisites","text":"

    To build the website, you must have Python and poetry installed. If your distribution packages poetry, something like apt install python3-poetry is likely the best way to install it. Otherwise, you can download Python from https://python.org or follow the Python installation instructions. Finally, follow the Poetry installation instructions.

    Once you have poetry installed, you should ask it to install the rest of the required tools into a virtual environment as follows:

    # --no-root avoids a harmless error message starting with Poetry 1.7\npoetry install --no-root\n

    You may get requests to \"unlock a keyring\", an error messages about failing to do so, or, in the case of Poetry 1.7, it may simply hang indefinitely. The workaround is to either to unlock the keyring or to run the following, and then to try poetry install --no-root again:

    # For sh-compatible shells or recent versions of `fish`\nexport PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring\n
    "},{"location":"contributing/#building-the-html-docs-locally-with-live-reload","title":"Building the HTML docs locally (with live reload)","text":"

    The HTML docs are built with MkDocs. After following the above steps, you should be able to view the docs by running

    # Note: this and all the commands below should be run from the root of\n# the `jj` source tree.\npoetry run -- mkdocs serve\n

    and opening http://127.0.0.1:8000 in your browser.

    As you edit the md files, the website should be rebuilt and reloaded in your browser automatically, unless build errors occur.

    You should occasionally check the terminal from which you ran mkdocs serve for any build errors or warnings. Warnings about \"GET /versions.json HTTP/1.1\" code 404 are expected and harmless.

    "},{"location":"contributing/#how-to-build-the-entire-website-not-usually-necessary","title":"How to build the entire website (not usually necessary)","text":"

    The full jj website includes the documentation for several jj versions (prerelease, latest release, and the older releases). The top-level URL https://martinvonz.github.io/jj redirects to https://martinvonz.github.io/jj/latest, which in turn redirects to the docs for the last stable version.

    The different versions of documentation are managed and deployed with mike, which can be run with poetry run -- mike.

    On a POSIX system or WSL, one way to build the entire website is as follows (on Windows, you'll need to understand and adapt the shell script):

    1. Check out jj as a co-located jj + git repository (jj clone --colocate), cloned from your fork of jj (e.g. jjfan.github.com/jj). You can also use a pure Git repo if you prefer.

    2. Make sure jjfan.github.com/jj includes the gh-pages branch of the jj repo and run git fetch origin gh-pages.

    3. Go to the GitHub repository settings, enable GitHub Pages, and configure them to use the gh-pages branch (this is usually the default).

    4. Run the same sh script that is used in GitHub CI (details below):

      .github/scripts/docs-build-deploy 'https://jjfan.github.io/jj/'\\\n    prerelease main --push\n

      This should build the version of the docs from the current commit, deploy it as a new commit to the gh-pages branch, and push the gh-pages branch to the origin.

    5. Now, you should be able to see the full website, including your latest changes to the prerelease version, at https://jjfan.github.io/jj/prerelease/.

    6. (Optional) The previous steps actually only rebuild https://jjfan.github.io/jj/prerelease/ and its alias https://jjfan.github.io/jj/main/. If you'd like to test out version switching back and forth, you can also rebuild the docs for the latest release as follows.

      jj new v1.33.1  # Let's say `jj 1.33.1` is the currently the latest release\n.github/scripts/docs-build-deploy 'https://jjfan.github.io/jj/'\\\n    v1.33.1 latest --push\n
    7. (Optional) When you are done, you may want to reset the gh-branches to the same spot as it is in the upstream. If you configured the upstream remote, this can be done with:

      # This will LOSE any changes you made to `gh-pages`\njj git fetch --remote upstream\njj branch set gh-pages -r gh-pages@upstream\njj git push --remote origin --branch gh-pages\n

      If you want to preserve some of the changes you made, you can do jj branch set my-changes -r gh-pages BEFORE running the above commands.

    "},{"location":"contributing/#explanation-of-the-docs-build-deploy-script","title":"Explanation of the docs-build-deploy script","text":"

    The script sets up the site_url mkdocs config to 'https://jjfan.github.io/jj/'. If this config does not match the URL where you loaded the website, some minor website features (like the version switching widget) will have reduced functionality.

    Then, the script passes the rest of its arguments to potery run -- mike deploy, which does the rest of the job. Run poetry run -- mike help deploy to find out what the arguments do.

    If you need to do something more complicated, you can use poetry run -- mike ... commands. You can also edit the gh-pages branch directly, but take care to avoid files that will be overwritten by future invocations of mike. Then, you can submit a PR based on the gh-pages branch of https://martinvonz.github.com/jj (instead of the usual main branch).

    "},{"location":"contributing/#modifying-protobuffers-this-is-not-common","title":"Modifying protobuffers (this is not common)","text":"

    Occasionally, you may need to change the .proto files that define jj's data storage format. In this case, you will need to add a few steps to the above workflow.

    • Install the protoc compiler. This usually means either apt-get install protobuf-compiler or downloading an official release. The prost library docs have additional advice.
    • Run cargo run -p gen-protos regularly (or after every edit to a .proto file). This is the same as running cargo run from lib/gen-protos. The gen-protos binary will use the prost-build library to compile the .proto files into .rs files.
    • If you are adding a new .proto file, you will need to edit the list of these files in lib/gen-protos/src/main.rs.

    The .rs files generated from .proto files are included in the repository, and there is a GitHub CI check that will complain if they do not match.

    "},{"location":"contributing/#profiling","title":"Profiling","text":"

    One easy-to-use sampling profiler is samply. For example:

    cargo install samply\nsamply record jj diff\n
    Then just open the link it prints.

    Another option is to use the instrumentation we've added manually (using tracing::instrument) in various places. For example:

    JJ_TRACE=/tmp/trace.json jj diff\n
    Then go to https://ui.perfetto.dev/ in Chrome and load /tmp/trace.json from there.

    "},{"location":"git-comparison/","title":"Comparison with Git","text":""},{"location":"git-comparison/#introduction","title":"Introduction","text":"

    This document attempts to describe how Jujutsu is different from Git. See the Git-compatibility doc for information about how the jj command interoperates with Git repos.

    "},{"location":"git-comparison/#overview","title":"Overview","text":"

    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 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 commit. Details.
    • There's no index (staging area). Because the working copy is automatically committed, an index-like concept doesn't make sense. The index is very similar to an intermediate commit between HEAD and the working copy, so workflows that depend on it can be modeled using proper commits instead. Jujutsu has excellent support for moving changes between commits. Details.
    • No need for branch names (but they are supported). Git lets you check out a commit without attaching a branch. It calls this state \"detached HEAD\". This is the normal state in Jujutsu (there's actually no way -- yet, at least -- to have an active branch). However, Jujutsu keeps track of all visible heads (leaves) of the commit graph, so the commits won't get lost or garbage-collected.
    • No current branch. Git lets you check out a branch, making it the 'current branch', and new commits will automatically update the branch. This is necessary in Git because Git might otherwise lose track of the new commits. Jujutsu does not have a 'current branch'; instead, you update branches manually. For example, if you check out a commit with a branch, new commits are created on top of the branch, then you issue a later command to update the branch.
    • Conflicts can be committed. No commands fail because of merge conflicts. The conflicts are instead recorded in commits and you can resolve them later. Details.
    • Descendant commits are automatically rebased. Whenever you rewrite a commit (e.g. by running jj rebase), all its descendants commits will automatically be rebased on top. Branches pointing to it will also get updated, and so will the working copy if it points to any of the rebased commits.
    • Branches are identified by their names (across remotes). For example, if you pull from a remote that has a main branch, you'll get a branch by that name in your local repo as well. If you then move it and push back to the remote, the main branch on the remote will be updated. Details.
    • The operation log replaces reflogs. The operation log is similar to reflogs, but is much more powerful. It keeps track of atomic updates to all refs at once (Jujutsu thus improves on Git's per-ref history much in the same way that Subversion improved on RCS's per-file history). The operation log powers e.g. the undo functionality. Details
    • There's a single, virtual root commit. Like Mercurial, Jujutsu has a virtual commit (with a hash consisting of only zeros) called the \"root commit\" (called the \"null revision\" in Mercurial). This commit is a common ancestor of all commits. That removes the awkward state Git calls the \"unborn branch\" state (which is the state a newly initialized Git repo is in), and related command-line flags (e.g. git rebase --root, git checkout --orphan).
    "},{"location":"git-comparison/#the-index","title":"The index","text":"

    Git's \"index\" has multiple roles. One role is as a cache of file system information. Jujutsu has something similar. Unfortunately, Git exposes the index to the user, which makes the CLI unnecessarily complicated (learning what the different flavors of git reset do, especially when combined with commits and/or paths, usually takes a while). Jujutsu, like Mercurial, doesn't make that mistake.

    As a Git power-user, you may think that you need the power of the index to commit only part of the working copy. However, Jujutsu provides commands for more directly achieving most use cases you're used to using Git's index for. For example, to create a commit from part of the changes in the working copy, you might be used to using git add -p; git commit. With Jujutsu, you'd instead use jj split to split the working-copy commit into two commits. To add more 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 <file> to move a specific file.

    "},{"location":"git-comparison/#command-equivalence-table","title":"Command equivalence table","text":"

    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/amend -r <revision> will move the diff from that revision into its parent.

    Use case Jujutsu command Git command Create a new repo jj git init [--colocate] git init Clone an existing repo jj git clone <source> <destination> (there is no support for cloning non-Git repos yet) git clone <source> <destination> Update the local repo with all branches from a remote jj git fetch [--remote <remote>] (there is no support for fetching into non-Git repos yet) git fetch [<remote>] Update a remote repo with all branches from the local repo jj git push --all [--remote <remote>] (there is no support for pushing from non-Git repos yet) git push --all [<remote>] Update a remote repo with a single branch from the local repo jj git push --branch <branch name> [--remote <remote>] (there is no support for pushing from non-Git repos yet) git push <remote> <branch name> Show summary of current work and repo status jj st git status Show diff of the current change jj diff git diff HEAD Show diff of another change jj diff -r <revision> git diff <revision>^ <revision> Show diff from another change to the current change jj diff --from <revision> git diff <revision> Show diff from change A to change B jj diff --from A --to B git diff A B Show description and diff of a change jj show <revision> git show <revision> Add a file to the current change touch filename touch filename; git add filename Remove a file from the current change rm filename git rm filename Modify a file in the current change echo stuff >> filename echo stuff >> filename Finish work on the current change and start a new change jj commit git commit -a See log of ancestors of the current commit jj log -r ::@ git log --oneline --graph --decorate See log of all reachable commits jj log -r 'all()' or jj log -r :: git log --oneline --graph --decorate --branches Show log of commits not on the main branch jj log (TODO) Search among files versioned in the repository grep foo $(jj files), or rg --no-require-git foo git grep foo Abandon the current change and start a new change jj abandon git reset --hard (cannot be undone) Make the current change empty jj restore git reset --hard (same as abandoning a change since Git has no concept of a \"change\") Abandon the parent of the working copy, but keep its diff in the working copy jj squash --from @- git reset --soft HEAD~ Discard working copy changes in some files jj restore <paths>... git restore <paths>... or git checkout HEAD -- <paths>... Edit description (commit message) of the current change jj describe Not supported Edit description (commit message) of the previous change jj describe @- git commit --amend (first make sure that nothing is staged) Temporarily put away the current change jj new @- (the old working-copy commit remains as a sibling commit) (the old working-copy commit X can be restored with jj edit X) git stash Start working on a new change based on the <main> branch jj new main git switch -c topic main or git checkout -b topic main (may need to stash or commit first) Move branch A onto branch B jj rebase -b A -d B git rebase B A (may need to rebase other descendant branches separately) Move change A and its descendants onto change B jj rebase -s A -d B git 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-D jj rebase -r C -d A; jj 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 change jj squash/amend git commit --amend -a Interactively move part of the diff in the current change into the parent change jj squash/amend -i git add -p; git commit --amend Move the diff in the working copy into an ancestor jj squash --into X git commit --fixup=X; git rebase -i --autosquash X^ Interactively move part of the diff in an arbitrary change to another arbitrary change jj squash -i --from X --into Y Not supported Interactively split the changes in the working copy in two jj split git commit -p Interactively split an arbitrary change in two jj split -r <revision> Not supported (can be emulated with the \"edit\" action in git rebase -i) Interactively edit the diff in a given change jj diffedit -r <revision> Not supported (can be emulated with the \"edit\" action in git rebase -i) Resolve conflicts and continue interrupted operation echo resolved > filename; jj squash/amend (operations don't get interrupted, so no need to continue) echo resolved > filename; git add filename; git rebase/merge/cherry-pick --continue Create a copy of a commit on top of another commit jj duplicate <source>; jj rebase -r <duplicate commit> -d <destination> (there's no single command for it yet) git co <destination>; git cherry-pick <source> Find the root of the working copy (or check if in a repo) jj workspace root git rev-parse --show-toplevel List branches jj branch list git branch Create a branch jj branch create <name> -r <revision> git branch <name> <revision> Move a branch forward jj branch set <name> -r <revision> git branch -f <name> <revision> Move a branch backward or sideways jj branch set <name> -r <revision> --allow-backwards git branch -f <name> <revision> Delete a branch jj branch delete <name> git branch --delete <name> See log of operations performed on the repo jj op log Not supported Undo an earlier operation jj [op] undo <operation ID> (jj undo is an alias for jj op undo) Not supported Create a commit that cancels out a previous commit jj backout -r <revision> git revert <revision>"},{"location":"git-compatibility/","title":"Git compatibility","text":"

    Jujutsu has two backends for storing commits. One of them uses a regular Git repo, which means that you can collaborate with Git users without them even knowing that you're not using the git CLI.

    See jj help git for help about the jj git family of commands, and e.g. jj help git push for help about a specific command (use jj git push -h for briefer help).

    "},{"location":"git-compatibility/#supported-features","title":"Supported features","text":"

    The following list describes which Git features Jujutsu is compatible with. For a comparison with Git, including how workflows are different, see the Git-comparison doc.

    • Configuration: Partial. The only configuration from Git (e.g. in ~/.gitconfig) that's respected is the following. Feel free to file a bug if you miss any particular configuration options.
      • The configuration of remotes ([remote \"<name>\"]).
      • core.excludesFile
    • Authentication: Partial. Only ssh-agent, a password-less key ( only ~/.ssh/id_rsa, ~/.ssh/id_ed25519 or ~/.ssh/id_ed25519_sk), or a credential.helper.
    • Branches: Yes. You can read more about how branches work in Jujutsu and how they interoperate with Git.
    • Tags: Partial. You can check out tagged commits by name (pointed to be either annotated or lightweight tags), but you cannot create new tags.
    • .gitignore: Yes. Ignores in .gitignore files are supported. So are ignores in .git/info/exclude or configured via Git's core.excludesfile config. The .gitignore support uses a native implementation, so please report a bug if you notice any difference compared to git.
    • .gitattributes: No. There's #53 about adding support for at least the eol attribute.
    • Hooks: No. There's #405 specifically for providing the checks from https://pre-commit.com.
    • Merge commits: Yes. Octopus merges (i.e. with more than 2 parents) are also supported.
    • Detached HEAD: Yes. Jujutsu supports anonymous branches, so this is a natural state.
    • Orphan branch: Yes. Jujutsu has a virtual root commit that appears as parent of all commits Git would call \"root commits\".
    • Staging area: Kind of. The staging area will be ignored. For example, jj diff will show a diff from the Git HEAD to the working copy. There are ways of fulfilling your use cases without a staging area.
    • Garbage collection: Yes. It should be safe to run git gc in the Git repo, but it's not tested, so it's probably a good idea to make a backup of the whole workspace first. There's no garbage collection and repacking of Jujutsu's own data structures yet, however.
    • Bare repositories: Yes. You can use jj git init --git-repo=<path> to create a repo backed by a bare Git repo.
    • Submodules: No. They will not show up in the working copy, but they will not be lost either.
    • Partial clones: No. We use the libgit2 library, which doesn't have support for partial clones.
    • Shallow clones: No. We use the libgit2 library, which doesn't have support for shallow clones.
    • git-worktree: No. However, there's native support for multiple working copies backed by a single repo. See the jj workspace family of commands.
    • Sparse checkouts: No. However, there's native support for sparse checkouts. See the jj sparse command.
    • Signed commits: No. (#58)
    • Git LFS: No. (#80)
    "},{"location":"git-compatibility/#creating-an-empty-repo","title":"Creating an empty repo","text":"

    To create an empty repo using the Git backend, use jj init --git <name>. Since the command creates a Jujutsu repo, it will have a .jj/ directory. The underlying Git repo will be inside of that directory (currently in .jj/repo/store/git/).

    "},{"location":"git-compatibility/#creating-a-repo-backed-by-an-existing-git-repo","title":"Creating a repo backed by an existing Git repo","text":"

    To create a Jujutsu repo backed by a Git repo you already have on disk, use jj git init --git-repo=<path to Git repo> <name>. The repo will work similar to a Git worktree, meaning that the working copies files and the record of the working-copy commit will be separate, but the commits will be accessible in both repos. Use jj git import to update the Jujutsu repo with changes made in the Git repo. Use jj git export to update the Git repo with changes made in the Jujutsu repo.

    "},{"location":"git-compatibility/#creating-a-repo-by-cloning-a-git-repo","title":"Creating a repo by cloning a Git repo","text":"

    To create a Jujutsu repo from a remote Git URL, use jj git clone <URL> [<destination>]. For example, jj git clone https://github.com/octocat/Hello-World will clone GitHub's \"Hello-World\" repo into a directory by the same name.

    "},{"location":"git-compatibility/#co-located-jujutsugit-repos","title":"Co-located Jujutsu/Git repos","text":"

    A \"co-located\" Jujutsu repo is a hybrid Jujutsu/Git repo. These can be created if you initialize the Jujutsu repo in an existing Git repo by running jj git init --colocate or with jj git clone --colocate. The Git repo and the Jujutsu repo then share the same working copy. Jujutsu will import and export from and to the Git repo on every jj command automatically.

    This mode is very convenient when tools (e.g. build tools) expect a Git repo to be present.

    It is allowed to mix jj and git commands in such a repo in any order. However, it may be easier to keep track of what is going on if you mostly use read-only git commands and use jj to make changes to the repo. One reason for this (see below for more) is that jj commands will usually put the git repo in a \"detached HEAD\" state, since in jj there is not concept of a \"currently tracked branch\". Before doing mutating Git commands, you may need to tell Git what the current branch should be with a git switch command.

    You can undo the results of mutating git commands using jj undo and jj op restore. Inside jj op log, changes by git will be represented as an \"import git refs\" operation.

    There are a few downsides to this mode of operation. Generally, using co-located repos may require you to deal with more involved Jujutsu and Git concepts.

    • Interleaving jj and git commands increases the chance of confusing branch conflicts or conflicted (AKA divergent) change ids. These never lose data, but can be annoying.

      Such interleaving can happen unknowingly. For example, some IDEs can cause it because they automatically run git fetch in the background from time to time.

    • In co-located repos with a very large number of branches or other refs, jj commands can get noticeably slower because of the automatic jj git import executed on each command. This can be mitigated by occasionally running jj util gc to speed up the import (that command includes packing the Git refs).

    • Git tools will have trouble with revisions that contain conflicted files. While jj renders these files with conflict markers in the working copy, they are stored in a non-human-readable fashion inside the repo. Git tools will often see this non-human-readable representation.

    • When a jj branch is conflicted, the position of the branch in the Git repo will disagree with one or more of the conflicted positions. The state of that branch in git will be labeled as though it belongs to a remote named \"git\", e.g. branch@git.

    • Jujutsu will ignore Git's staging area. It will not understand merge conflicts as Git represents them, unfinished git rebase states, as well as other less common states a Git repository can be in.

    • Colocated repositories are less resilient to concurrency issues if you share the repo using an NFS filesystem or Dropbox. In general, such use of Jujutsu is not currently thoroughly tested.

    • There may still be bugs when interleaving mutating jj and git commands, usually having to do with a branch pointer ending up in the wrong place. We are working on the known ones, and are not aware of any major ones. Please report any new ones you find, or if any of the known bugs are less minor than they appear.

    "},{"location":"git-compatibility/#converting-a-repo-into-a-co-located-repo","title":"Converting a repo into a co-located repo","text":"

    A Jujutsu repo backed by a Git repo has a full Git repo inside, so it is technically possible (though not officially supported) to convert it into a co-located repo like so:

    # Move the Git repo\nmv .jj/repo/store/git .git\n# Tell jj where to find it\necho -n '../../../.git' > .jj/repo/store/git_target\n# Ignore the .jj directory in Git\necho '/*' > .jj/.gitignore\n# Make the Git repository non-bare and set HEAD\ngit config --unset core.bare\njj st\n

    We may officially support this in the future. If you try this, we would appreciate feedback and bug reports.

    "},{"location":"git-compatibility/#branches","title":"Branches","text":"

    TODO: Describe how branches are mapped

    "},{"location":"git-compatibility/#format-mapping-details","title":"Format mapping details","text":"

    Paths are assumed to be UTF-8. I have no current plans to support paths with other encodings.

    Commits created by jj have a ref starting with refs/jj/ to prevent GC.

    Commit metadata that cannot be represented in Git commits (such as the Change ID and information about conflicts) is stored outside of the Git repo (currently in .jj/store/extra/).

    Commits with conflicts cannot be represented in Git. They appear in the Git commit as as root directories called.jjconflict-base-*/ and .jjconflict-side-*/. Note that the purpose of this representation is only to prevent GC of the relevant trees; the authoritative information is in the Git-external storage mentioned in the paragraph above. As long as you use jj commands to work with them, you won't notice those paths. If, on the other hand, you use e.g. git switch to check one of them out, you will see those directories in your working copy. If you then run e.g. jj status, the resulting snapshot will contain those directories, making it look like they replaced all the other paths in your repo. You will probably want to run jj abandon to get back to the state with the unresolved conflicts.

    "},{"location":"github/","title":"Using Jujutsu with GitHub and GitLab Projects","text":"

    This guide assumes a basic understanding of either Git or Mercurial.

    "},{"location":"github/#set-up-an-ssh-key","title":"Set up an SSH key","text":"

    As of October 2023 it's recommended to set up an SSH key to work with GitHub projects. See GitHub's Tutorial. This restriction may be lifted in the future, see issue #469 for more information and progress on authenticated HTTP.

    "},{"location":"github/#basic-workflow","title":"Basic workflow","text":"

    The simplest way to start with Jujutsu is to create a stack of commits first. You will only need to create a branch when you need to push the stack to a remote. There are two primary workflows: using a generated branch name or naming a branch.

    "},{"location":"github/#using-a-generated-branch-name","title":"Using a generated branch name","text":"

    In this example we're letting Jujutsu auto-create a branch.

    # Start a new commit off of the default branch.\n$ jj new main\n# Refactor some files, then add a description and start a new commit\n$ jj commit -m 'refactor(foo): restructure foo()'\n# Add a feature, then add a description and start a new commit\n$ jj commit -m 'feat(bar): add support for bar'\n# Let Jujutsu generate a branch name and push that to GitHub. Note that we\n# push the working-copy commit's *parent* because the working-copy commit\n# itself is empty.\n$ jj git push -c @-\n
    "},{"location":"github/#using-a-named-branch","title":"Using a named branch","text":"

    In this example, we create a branch named bar and then push it to the remote.

    # Start a new commit off of the default branch.\n$ jj new main\n# Refactor some files, then add a description and start a new commit\n$ jj commit -m 'refactor(foo): restructure foo()'\n# Add a feature, then add a description and start a new commit\n$ jj commit -m 'feat(bar): add support for bar'\n# Create a branch so we can push it to GitHub. Note that we created the branch\n# on the working-copy commit's *parent* because the working copy itself is empty.\n$ jj branch create bar -r @- # `bar` now contains the previous two commits.\n# Push the branch to GitHub (pushes only `bar`)\n$ jj git push\n

    While it's possible to create a branch in advance and commit on top of it in a Git-like manner, you will then need to move the branch manually when you create a new commits. Unlike Git, Jujutsu will not do it automatically.

    "},{"location":"github/#updating-the-repository","title":"Updating the repository","text":"

    As of October 2023, Jujutsu has no equivalent to a git pull command (see issue #1039). Until such a command is added, you need to use jj git fetch followed by a jj rebase -d $main_branch to update your changes.

    "},{"location":"github/#working-in-a-git-co-located-repository","title":"Working in a Git co-located repository","text":"

    After doing jj git init --colocate, Git will be in a detached HEAD state, which is unusual, as Git mainly works with branches. In a co-located repository, every jj command will automatically synchronize Jujutsu's view of the repo with Git's view. For example, jj commit updates the HEAD of the Git repository, enabling an incremental migration.

    $ nvim docs/tutorial.md\n$ # Do some more work.\n$ jj commit -m \"Update tutorial\"\n# Create a branch on the working-copy commit's parent\n$ jj branch create doc-update -r @-\n$ jj git push\n
    "},{"location":"github/#working-in-a-jujutsu-repository","title":"Working in a Jujutsu repository","text":"

    In a Jujutsu repository, the workflow is simplified. If there's no need for explicitly named branches, you can just generate one for a change. As Jujutsu is able to create a branch for a revision.

    $ # Do your work\n$ jj commit\n$ # Push change \"mw\", letting Jujutsu automatically create a branch called\n$ # \"push-mwmpwkwknuz\"\n$ jj git push --change mw\n
    "},{"location":"github/#addressing-review-comments","title":"Addressing review comments","text":"

    There are two workflows for addressing review comments, depending on your project's preference. Many projects prefer that you address comments by adding commits to your branch1. Some projects (such as Jujutsu and LLVM) instead prefer that you keep your commits clean by rewriting them and then force-pushing2.

    "},{"location":"github/#adding-new-commits","title":"Adding new commits","text":"

    If your project prefers that you address review comments by adding commits on top, you can do that by doing something like this:

    $ # Create a new commit on top of the `your-feature` branch from above.\n$ jj new your-feature\n$ # Address the comments by updating the code. Then review the changes.\n$ jj diff\n$ # Give the fix a description and create a new working-copy on top.\n$ jj commit -m 'address pr comments'\n$ # Update the branch to point to the new commit.\n$ jj branch set your-feature -r @-\n$ # Push it to your remote\n$ jj git push\n

    Notably, the above workflow creates a new commit for you. The same can be achieved without creating a new commit.

    Warning We strongly suggest to jj new after the example below, as all further edits still get amended to the previous commit.

    $ # Create a new commit on top of the `your-feature` branch from above.\n$ jj new your-feature\n$ # Address the comments by updating the code. Then review the changes.\n$ jj diff\n$ # Give the fix a description.\n$ jj describe -m 'address pr comments'\n$ # Update the branch to point to the current commit.\n$ jj branch set your-feature -r @\n$ # Push it to your remote\n$ jj git push\n
    "},{"location":"github/#rewriting-commits","title":"Rewriting commits","text":"

    If your project prefers that you keep commits clean, you can do that by doing something like this:

    $ # Create a new commit on top of the second-to-last commit in `your-feature`,\n$ # as reviewers requested a fix there.\n$ jj new your-feature- # NOTE: the trailing hyphen is not a typo!\n$ # Address the comments by updating the code. Then review the changes.\n$ jj diff\n$ # Squash the changes into the parent commit\n$ jj squash\n$ # Push the updated branch to the remote. Jujutsu automatically makes it a\n$ # force push\n$ jj git push --branch your-feature\n

    The hyphen after your-feature comes from the revset syntax.

    "},{"location":"github/#working-with-other-peoples-branches","title":"Working with other people's branches","text":"

    By default, jj git clone imports the default remote branch (which is usually main or master), but jj git fetch doesn't import new remote branches to local branches. This means that if you want to iterate or test another contributor's branch, you'll need to do jj new <branch>@<remote> onto it.

    If you want to import all remote branches including inactive ones, set git.auto-local-branch = true in the config file. Then you can specify a contributor's branch as jj new <branch> instead of jj new <branch>@<remote>.

    You can find more information on that setting here.

    "},{"location":"github/#using-github-cli","title":"Using GitHub CLI","text":"

    GitHub CLI will have trouble finding the proper Git repository path in jj repos that aren't co-located (see issue #1008). You can configure the $GIT_DIR environment variable to point it to the right path:

    $ GIT_DIR=.jj/repo/store/git gh issue list\n

    You can make that automatic by installing direnv and defining hooks in a .envrc file in the repository root to configure $GIT_DIR. Just add this line into .envrc:

    export GIT_DIR=$PWD/.jj/repo/store/git\n

    and run direnv allow to approve it for direnv to run. Then GitHub CLI will work automatically even in repos that aren't co-located so you can execute commands like gh issue list normally.

    "},{"location":"github/#useful-revsets","title":"Useful Revsets","text":"

    Log all revisions across all local branches that aren't on the main branch nor on any remote:

    $ jj log -r 'branches() & ~(main | remote_branches())'\n

    Log all revisions that you authored, across all branches that aren't on any remote:

    $ jj log -r 'mine() & branches() & ~remote_branches()'\n

    Log all remote branches that you authored or committed to:

    $ jj log -r 'remote_branches() & (mine() | committer(your@email.com))'\n

    Log all descendants of the current working copy that aren't on any remote:

    $ jj log -r '::@ & ~remote_branches()'\n
    "},{"location":"github/#merge-conflicts","title":"Merge conflicts","text":"

    For a detailed overview, how Jujutsu handles conflicts, revisit the tutorial.

    "},{"location":"github/#using-several-remotes","title":"Using several remotes","text":"

    It is common to use several remotes when contributing to a shared repository. For example, \"upstream\" can designate the remote where the changes will be merged through a pull-request while \"origin\" is your private fork of the project. In this case, you might want to jj git fetch from \"upstream\" and to jj git push to \"origin\".

    You can configure the default remotes to fetch from and push to in your configuration file (for example .jj/repo/config.toml):

    [git]\nfetch = \"upstream\"\npush = \"origin\"\n

    The default for both git.fetch and git.push is \"origin\".

    1. This is a GitHub-style review, as GitHub currently only is able to compare branches.\u00a0\u21a9

    2. If you're wondering why we prefer clean commits in this project, see e.g. this blog post \u21a9

    "},{"location":"glossary/","title":"Glossary","text":""},{"location":"glossary/#anonymous-branch","title":"Anonymous branch","text":"

    An anonymous branch is a chain of commits that doesn't have any named branches pointing to it or to any of its descendants. Unlike Git, Jujutsu keeps commits on anonymous branches around until they are explicitly abandoned. Visible anonymous branches are tracked by the view, which stores a list of heads of such branches.

    "},{"location":"glossary/#backend","title":"Backend","text":"

    A backend is an implementation of the storage layer. There are currently two builtin commit backends: the Git backend and the native backend. The Git backend stores commits in a Git repository. The native backend is used for testing purposes only. Alternative backends could be used, for example, if somebody wanted to use jj with a humongous monorepo (as Google does).

    There are also pluggable backends for storing other information than commits, such as the \"operation store backend\" for storing the operation log.

    "},{"location":"glossary/#branch","title":"Branch","text":"

    A branch is a named pointer to a commit. They automatically follow the commit if it gets rewritten. Branches are sometimes called \"named branches\" to distinguish them from anonymous branches, but note that they are more similar to Git's branches than to Mercurial's named branches. See here for details.

    "},{"location":"glossary/#change","title":"Change","text":"

    A change is a commit as it evolves over time.

    "},{"location":"glossary/#change-id","title":"Change ID","text":"

    A change ID is a unique identifier for a change. They are typically 16 bytes long and are often randomly generated. By default, jj log presents them as a sequence of 12 letters in the k-z range, at the beginning of a line. These are actually hexadecimal numbers that use \"digits\" z-k instead of 0-9a-f.

    For the git backend, Change IDs are currently maintained only locally and not exchanged via push/fetch operations.

    "},{"location":"glossary/#commit","title":"Commit","text":"

    A snapshot of the files in the repository at a given point in time (technically a tree object), together with some metadata. The metadata includes the author, the date, and pointers to the commit's parents. Through the pointers to the parents, the commits form a Directed Acyclic Graph (DAG) .

    Note that even though commits are stored as snapshots, they are often treated as differences between snapshots, namely compared to their parent's snapshot. If they have more than one parent, then the difference is computed against the result of merging the parents. For example, jj diff will show the differences introduced by a commit compared to its parent(s), and jj rebase will apply those changes onto another base commit.

    The word \"revision\" is used as a synonym for \"commit\".

    "},{"location":"glossary/#commit-id","title":"Commit ID","text":"

    A commit ID is a unique identifier for a commit. They are 20 bytes long when using the Git backend. They are presented in regular hexadecimal format at the end of the line in jj log, using 12 hexadecimal digits by default. When using the Git backend, the commit ID is the Git commit ID.

    "},{"location":"glossary/#co-located-repos","title":"Co-located repos","text":"

    When using the Git backend and the backing Git repository's .git/ directory is a sibling of .jj/, we call the repository \"co-located\". Most tools designed for Git can be easily used on such repositories. jj and git commands can be used interchangeably.

    See here for details.

    "},{"location":"glossary/#conflict","title":"Conflict","text":"

    Conflicts can occur in many places. The most common type is conflicts in files. Those are the conflicts that users coming from other VCSs are usually familiar with. You can see them in jj status and in jj log (the red \"conflict\" label at the end of the line). See here for details.

    Conflicts can also occur in branches. For example, if you moved a branch locally, and it was also moved on the remote, then the branch will be in a conflicted state after you pull from the remote. See here for details.

    Similar to a branch conflict, when a change is rewritten locally and remotely, for example, then the change will be in a conflicted state. We call that a divergent change.

    "},{"location":"glossary/#divergent-change","title":"Divergent change","text":"

    A divergent change is a change that has more than one visible commit.

    "},{"location":"glossary/#head","title":"Head","text":"

    A head is a commit with no descendants. The context in which it has no descendants varies. For example, the heads(X) revset function returns commits that have no descendants within the set X itself. The view records which anonymous heads (heads without a branch pointing to them) are visible at a given operation. Note that this is quite different from Git's HEAD.

    "},{"location":"glossary/#hidden-commits-abandoned-commits","title":"Hidden commits, abandoned commits","text":"

    See visible commits.

    "},{"location":"glossary/#operation","title":"Operation","text":"

    A snapshot of the visible commits and branches at a given point in time (technically a view object), together with some metadata. The metadata includes the username, hostname, timestamps, and pointers to the operation's parents.

    "},{"location":"glossary/#operation-log","title":"Operation log","text":"

    The operation log is the DAG formed by operation objects, much in the same way that commits form a DAG, which is sometimes called the \"commit history\". When operations happen in sequence, they form a single line in the graph. Operations that happen concurrently from jj's perspective result in forks and merges in the DAG.

    "},{"location":"glossary/#repository","title":"Repository","text":"

    Basically everything under .jj/, i.e. the full set of operations and commits.

    "},{"location":"glossary/#remote","title":"Remote","text":"

    TODO

    "},{"location":"glossary/#revision","title":"Revision","text":"

    A synonym for Commit.

    "},{"location":"glossary/#revset","title":"Revset","text":"

    Jujutsu supports a functional language for selecting a set of revisions. Expressions in this language are called \"revsets\". See here for details. We also often use the term \"revset\" for the set of revisions selected by a revset.

    "},{"location":"glossary/#rewrite","title":"Rewrite","text":"

    To \"rewrite\" a commit means to create a new version of that commit with different contents, metadata (including parent pointers), or both. Rewriting a commit results in a new commit, and thus a new commit ID, but the change ID generally remains the same. Some examples of rewriting a commit would be changing its description or rebasing it. Modifying the working copy rewrites the working copy commit.

    "},{"location":"glossary/#root-commit","title":"Root commit","text":"

    The root commit is a virtual commit at the root of every repository. It has a commit ID consisting of all '0's (00000000...) and a change ID consisting of all 'z's (zzzzzzzz...). It can be referred to in revsets by the function root(). Note that our definition of \"root commit\" is different from Git's; Git's \"root commits\" are the first commit(s) in the repository, i.e. the commits jj log -r root()+ will show.

    "},{"location":"glossary/#tree","title":"Tree","text":"

    A tree object represents a snapshot of a directory in the repository. Tree objects are defined recursively; each tree object only has the files and directories contained directly in the directory it represents.

    "},{"location":"glossary/#tracked-branches-and-tracking-branches","title":"Tracked branches and tracking branches","text":"

    A remote branch can be made \"tracked\" with the jj branch track command. This results in a \"tracking\" local branch that tracks the remote branch.

    See the branches documentation for a more detailed definition of these terms.

    "},{"location":"glossary/#visible-commits","title":"Visible commits","text":"

    Visible commits are the commits you see in jj log -r 'all()'. They are the commits that are reachable from an anonymous head in the view. Ancestors of a visible commit are implicitly visible.

    Intuitively, visible commits are the \"latest versions\" of a revision with a given change id. A commit that's abandoned or rewritten stops being visible and is labeled as \"hidden\". Such commits are no longer accessible using a change id, but they are still accessible by their commit id.

    "},{"location":"glossary/#view","title":"View","text":"

    A view is a snapshot of branches and their targets, anonymous heads, and working-copy commits. The anonymous heads define which commits are visible.

    A view object is similar to a tree object in that it represents a snapshot without history, and an operation object is similar to a commit object in that it adds metadata and history.

    "},{"location":"glossary/#workspace","title":"Workspace","text":"

    A workspace is a working copy and an associated repository. There can be multiple workspaces for a single repository. Each workspace has a .jj/ directory, but the commits and operations will be stored in the initial workspace; the other workspaces will have pointers to the initial workspace. See here for details.

    This is what Git calls a \"worktree\".

    "},{"location":"glossary/#working-copy","title":"Working copy","text":"

    The working copy contains the files you're currently working on. It is automatically snapshot at the beginning of almost every jj command, thus creating a new working-copy commit if any changes had been made in the working copy. Conversely, the working copy is automatically updated to the state of the working-copy commit at the end of almost every jj command. See here for details.

    This is what Git calls a \"working tree\".

    "},{"location":"glossary/#working-copy-commit","title":"Working-copy commit","text":"

    A commit that corresponds to the current state of the working copy. There is one working-copy commit per workspace. The current working-copy commits are tracked in the operation log.

    "},{"location":"install-and-setup/","title":"Installation and setup","text":""},{"location":"install-and-setup/#installation","title":"Installation","text":""},{"location":"install-and-setup/#download-pre-built-binaries-for-a-release","title":"Download pre-built binaries for a release","text":"

    There are pre-built binaries of the last released version of jj for Windows, Mac, or Linux (the \"musl\" version should work on all distributions).

    If you'd like to install a prerelease version, you'll need to use one of the options below.

    "},{"location":"install-and-setup/#cargo-binstall","title":"Cargo Binstall","text":"

    If you use cargo-binstall, you can install the same binaries of the last jj release from GitHub as follows:

    # Will put the jj binary for the latest release in ~/.cargo/bin by default\ncargo binstall --strategies crate-meta-data jj-cli\n

    Without the --strategies option, you may get equivalent binaries that should be compiled from the same source code.

    "},{"location":"install-and-setup/#linux","title":"Linux","text":""},{"location":"install-and-setup/#arch-linux","title":"Arch Linux","text":"

    You can install the jujutsu package from the official extra repository:

    pacman -S jujutsu\n

    Or install from the AUR repository with an AUR Helper:

    yay -S jujutsu-git\n
    "},{"location":"install-and-setup/#from-source","title":"From Source","text":"

    First make sure that you have the libssl-dev, openssl, pkg-config, and build-essential packages installed by running something like this:

    sudo apt-get install libssl-dev openssl pkg-config build-essential\n

    Now run either:

    # To install the *prerelease* version from the main branch\ncargo install --git https://github.com/martinvonz/jj.git --locked --bin jj jj-cli\n

    or:

    # To install the latest release\ncargo install --locked --bin jj jj-cli\n
    "},{"location":"install-and-setup/#nix-os","title":"Nix OS","text":"

    If you're on Nix OS you can install a released version of jj using the nixpkgs jujutsu package.

    To install a prerelease version, you can use the flake for this repository. For example, if you want to run jj loaded from the flake, use:

    nix run 'github:martinvonz/jj'\n

    You can also add this flake url to your system input flakes. Or you can install the flake to your user profile:

    # Installs the prerelease version from the main branch\nnix profile install 'github:martinvonz/jj'\n
    "},{"location":"install-and-setup/#homebrew","title":"Homebrew","text":"

    If you use linuxbrew, you can run:

    # Installs the latest release\nbrew install jj\n
    "},{"location":"install-and-setup/#mac","title":"Mac","text":""},{"location":"install-and-setup/#from-source_1","title":"From Source","text":"

    You may need to run some or all of these:

    xcode-select --install\nbrew install openssl\nbrew install pkg-config\nexport PKG_CONFIG_PATH=\"$(brew --prefix)/opt/openssl@3/lib/pkgconfig\"\n

    Now run either:

    # To install the *prerelease* version from the main branch\ncargo install --git https://github.com/martinvonz/jj.git --locked --bin jj jj-cli\n

    or:

    # To install the latest release\ncargo install --locked --bin jj jj-cli\n
    "},{"location":"install-and-setup/#homebrew_1","title":"Homebrew","text":"

    If you use Homebrew, you can run:

    # Installs the latest release\nbrew install jj\n
    "},{"location":"install-and-setup/#macports","title":"MacPorts","text":"

    You can also install jj via the MacPorts jujutsu port:

    # Installs the latest release\nsudo port install jujutsu\n
    "},{"location":"install-and-setup/#windows","title":"Windows","text":"

    Run either:

    # To install the *prerelease* version from the main branch\ncargo install --git https://github.com/martinvonz/jj.git --locked --bin jj jj-cli --features vendored-openssl\n

    or:

    # To install the latest release\ncargo install --locked --bin jj jj-cli --features vendored-openssl\n
    "},{"location":"install-and-setup/#initial-configuration","title":"Initial configuration","text":"

    You may want to configure your name and email so commits are made in your name.

    $ jj config set --user user.name \"Martin von Zweigbergk\"\n$ jj config set --user user.email \"martinvonz@google.com\"\n
    "},{"location":"install-and-setup/#command-line-completion","title":"Command-line completion","text":"

    To set up command-line completion, source the output of jj util completion bash/zsh/fish. Exactly how to source it depends on your shell.

    "},{"location":"install-and-setup/#bash","title":"Bash","text":"
    source <(jj util completion)  # --bash is the default\n
    "},{"location":"install-and-setup/#zsh","title":"Zsh","text":"
    autoload -U compinit\ncompinit\nsource <(jj util completion zsh)\n
    "},{"location":"install-and-setup/#fish","title":"Fish","text":"
    jj util completion fish | source\n
    "},{"location":"install-and-setup/#nushell","title":"Nushell","text":"
    jj util completion nushell | save completions-jj.nu\nuse completions-jj.nu *  # Or `source completions-jj.nu`\n
    "},{"location":"install-and-setup/#xonsh","title":"Xonsh","text":"
    source-bash $(jj util completion)\n
    "},{"location":"operation-log/","title":"Operation log","text":""},{"location":"operation-log/#introduction","title":"Introduction","text":"

    Jujutsu records each operation that modifies the repo in the \"operation log\". You can see the log with jj op log. Each operation object contains a snapshot of how the repo looked at the end of the operation. We call this snapshot a \"view\" object. The view contains information about where each branch, tag, and Git ref (in Git-backed repos) pointed, as well as the set of heads in the repo, and the current working-copy commit in each workspace. The operation object also (in addition to the view) contains pointers to the operation(s) immediately before it, as well as metadata about the operation, such as timestamps, username, hostname, description.

    The operation log allows you to undo an operation (jj [op] undo), which doesn't need to be the most recent one. It also lets you restore the entire repo to the way it looked at an earlier point (jj op restore).

    When referring to operations, you can use @ to represent the current operation.

    The following operators are supported:

    • x-: Parents of x (e.g. @-)
    • x+: Children of x
    "},{"location":"operation-log/#concurrent-operations","title":"Concurrent operations","text":"

    One benefit of the operation log (and the reason for its creation) is that it allows lock-free concurrency -- you can run concurrent jj commands without corrupting the repo, even if you run the commands on different machines that access the repo via a distributed file system (as long as the file system guarantees that a write is only visible once previous writes are visible). When you run a jj command, it will start by loading the repo at the latest operation. It will not see any changes written by concurrent commands. If there are conflicts, you will be informed of them by subsequent jj st and/or jj log commands.

    As an example, let's say you had started editing the description of a change and then also update the contents of the change (maybe because you had forgotten the editor). When you eventually close your editor, the command will succeed and e.g. jj log will indicate that the change has diverged.

    "},{"location":"operation-log/#loading-an-old-version-of-the-repo","title":"Loading an old version of the repo","text":"

    The top-level --at-operation/--at-op option allows you to load the repo at a specific operation. This can be useful for understanding how your repo got into the current state. It can be even more useful for understanding why someone else's repo got into its current state.

    When you use --at-op, the automatic snapshotting of the working copy will not take place. When referring to a revision with the @ symbol (as many commands do by default), that will resolve to the working-copy commit recorded in the operation's view (which is actually how it always works -- it's just the snapshotting that's skipped with --at-op).

    As a top-level option, --at-op can be passed to any command. However, you will typically only want to run read-only commands. For example, jj log, jj st, and jj diff all make sense. It's still possible to run e.g. jj --at-op=<some operation ID> describe. That's equivalent to having started jj describe back when the specified operation was the most recent operation and then let it run until now (which can be done for that particular command by not closing the editor). There's practically no good reason to do that other than to simulate concurrent commands.

    "},{"location":"related-work/","title":"Related work","text":"

    Similar tools:

    • git-branchless: Helps you use a branchless workflow in your Git repo. Supports anonymous branching, undo, and faster rebase (git move). Under heavy development and quickly gaining new features.
    • Sapling: A heavily modified fork of Mercurial developed and used at Meta. It is compatible with Git, has undo functionality, and a graphical interface. See how it is different from Jujutsu.
    • GitUp: A Mac-only GUI for Git. Like Jujutsu, supports undo and restoring the repo to an earlier snapshot. Backed by its GitUpKit library.
    • Gitless: Another attempt at providing a simpler interface for Git. Like Jujutsu, does not have an \"index\"/\"staging area\" concept. Also doesn't move the working-copy changes between branches (which we do simply as a consequence of making the working copy a commit).
    • Pijul: Architecturally quite different from Jujutsu, but its \"first-class conflicts\" feature seems quite similar to ours.
    • Breezy: Another VCS that's similar in that it has multiple storage backends, including its own format as well as .git support.
    • Sturdy: A Git backed GUI that eliminates local and remote as well as the idea of an \"index\"/\"staging area\".
    "},{"location":"revsets/","title":"Revsets","text":"

    Jujutsu supports a functional language for selecting a set of revisions. Expressions in this language are called \"revsets\" (the idea comes from Mercurial). The language consists of symbols, operators, and functions.

    Most jj commands accept a revset (or multiple). Many commands, such as jj diff -r <revset> expect the revset to resolve to a single commit; it is an error to pass a revset that resolves to more than one commit (or zero commits) to such commands.

    The words \"revisions\" and \"commits\" are used interchangeably in this document.

    Most revsets search only the visible commits. Other commits are only included if you explicitly mention them (e.g. by commit ID or a Git ref pointing to them).

    "},{"location":"revsets/#symbols","title":"Symbols","text":"

    The @ expression refers to the working copy commit in the current workspace. Use <workspace name>@ to refer to the working-copy commit in another workspace. Use <name>@<remote> to refer to a remote-tracking branch.

    A full commit ID refers to a single commit. A unique prefix of the full commit ID can also be used. It is an error to use a non-unique prefix.

    A full change ID refers to all visible commits with that change ID (there is typically only one visible commit with a given change ID). A unique prefix of the full change ID can also be used. It is an error to use a non-unique prefix.

    Use double quotes to prevent a symbol from being interpreted as an expression. For example, \"x-\" is the symbol x-, not the parents of symbol x. Taking shell quoting into account, you may need to use something like jj log -r '\"x-\"'.

    "},{"location":"revsets/#priority","title":"Priority","text":"

    Jujutsu attempts to resolve a symbol in the following order:

    1. Tag name
    2. Branch name
    3. Git ref
    4. Commit ID or change ID
    "},{"location":"revsets/#operators","title":"Operators","text":"

    The following operators are supported. x and y below can be any revset, not only symbols.

    • x & y: Revisions that are in both x and y.
    • x | y: Revisions that are in either x or y (or both).
    • x ~ y: Revisions that are in x but not in y.
    • ~x: Revisions that are not in x.
    • x-: Parents of x.
    • x+: Children of x.
    • ::x: Ancestors of x, including the commits in x itself.
    • x::: Descendants of x, including the commits in x itself.
    • x::y: Descendants of x that are also ancestors of y. Equivalent to x:: & ::y. This is what git log calls --ancestry-path x..y.
    • ::: All visible commits in the repo. Equivalent to all().
    • x..y: Ancestors of y that are not also ancestors of x. Equivalent to ::y ~ ::x. This is what git log calls x..y (i.e. the same as we call it).
    • ..x: Ancestors of x, including the commits in x itself, but excluding the root commit. Equivalent to ::x ~ root().
    • x..: Revisions that are not ancestors of x.
    • ..: All visible commits in the repo, but excluding the root commit. Equivalent to ~root().

    You can use parentheses to control evaluation order, such as (x & y) | z or x & (y | z).

    "},{"location":"revsets/#functions","title":"Functions","text":"

    You can also specify revisions by using functions. Some functions take other revsets (expressions) as arguments.

    • parents(x): Same as x-.

    • children(x): Same as x+.

    • ancestors(x[, depth]): ancestors(x) is the same as ::x. ancestors(x, depth) returns the ancestors of x limited to the given depth.

    • descendants(x): Same as x::.

    • connected(x): Same as x::x. Useful when x includes several commits.

    • all(): All visible commits in the repo.

    • none(): No commits. This function is rarely useful; it is provided for completeness.

    • branches([pattern]): All local branch targets. If pattern is specified, this selects the branches whose name match the given string pattern. For example, branches(push) would match the branches push-123 and repushed but not the branch main. If a branch is in a conflicted state, all its possible targets are included.

    • remote_branches([branch_pattern[, [remote=]remote_pattern]]): All remote branch targets across all remotes. If just the branch_pattern is specified, the branches whose names match the given string pattern across all remotes are selected. If both branch_pattern and remote_pattern are specified, the selection is further restricted to just the remotes whose names match remote_pattern.

      For example, remote_branches(push, ri) would match the branches push-123@origin and repushed@private but not push-123@upstream or main@origin or main@upstream. If a branch is in a conflicted state, all its possible targets are included.

      While Git-tracking branches can be selected by <name>@git, these branches aren't included in remote_branches().

    • tags(): All tag targets. If a tag is in a conflicted state, all its possible targets are included.

    • git_refs(): All Git ref targets as of the last import. If a Git ref is in a conflicted state, all its possible targets are included.

    • git_head(): The Git HEAD target as of the last import. Equivalent to present(HEAD@git).

    • visible_heads(): All visible heads (same as heads(all())).

    • root(): The virtual commit that is the oldest ancestor of all other commits.

    • heads(x): Commits in x that are not ancestors of other commits in x. Note that this is different from Mercurial's heads(x) function, which is equivalent to x ~ x-.

    • roots(x): Commits in x that are not descendants of other commits in x. Note that this is different from Mercurial's roots(x) function, which is equivalent to x ~ x+.

    • latest(x[, count]): Latest count commits in x, based on committer timestamp. The default count is 1.

    • merges(): Merge commits.

    • description(pattern): Commits that have a description matching the given string pattern.

    • author(pattern): Commits with the author's name or email matching the given string pattern.

    • mine(): Commits where the author's email matches the email of the current user.

    • committer(pattern): Commits with the committer's name or email matching the given string pattern.

    • empty(): Commits modifying no files. This also includes merges() without user modifications and root().

    • file(relativepath) or file(\"relativepath\"[, \"relativepath\"]...): Commits modifying one of the paths specified. Currently, string patterns are not supported in the path arguments.

      Paths are relative to the directory jj was invoked from. A directory name will match all files in that directory and its subdirectories.

      For example, file(foo) will match files foo, foo/bar, foo/bar/baz. It will not match foobar or bar/foo.

    • conflict(): Commits with conflicts.

    • present(x): Same as x, but evaluated to none() if any of the commits in x doesn't exist (e.g. is an unknown branch name.)

    "},{"location":"revsets/#string-patterns","title":"String patterns","text":"

    Functions that perform string matching support the following pattern syntax:

    • \"string\", or string (the quotes are optional), or substring:\"string\": Matches strings that contain string.
    • exact:\"string\": Matches strings exactly equal to string.
    • glob:\"pattern\": Matches strings with Unix-style shell wildcard pattern.
    "},{"location":"revsets/#aliases","title":"Aliases","text":"

    New symbols and functions can be defined in the config file, by using any combination of the predefined symbols/functions and other aliases.

    For example:

    [revset-aliases]\n'HEAD' = '@-'\n'user(x)' = 'author(x) | committer(x)'\n
    "},{"location":"revsets/#built-in-aliases","title":"Built-in Aliases","text":"

    The following aliases are built-in and used for certain operations. These functions are defined as aliases in order to allow you to overwrite them as needed. See revsets.toml for a comprehensive list.

    • trunk(): Resolves to the head commit for the trunk branch of the remote named origin or upstream. The branches main, master, and trunk are tried. If more than one potential trunk commit exists, the newest one is chosen. If none of the branches exist, the revset evaluates to root().

      You can override this as appropriate. If you do, make sure it always resolves to exactly one commit. For example:

      [revset-aliases]\n'trunk()' = 'your-branch@your-remote'\n
    • immutable_heads(): Resolves to trunk() | tags() by default. See here for details.

    "},{"location":"revsets/#examples","title":"Examples","text":"

    Show the parent(s) of the working-copy commit (like git log -1 HEAD):

    jj log -r @-\n

    Show all ancestors of the working copy (like plain git log)

    jj log -r ::@\n

    Show commits not on any remote branch:

    jj log -r 'remote_branches()..'\n

    Show commits not on origin (if you have other remotes like fork):

    jj log -r 'remote_branches(remote=origin)..'\n

    Show the initial commits in the repo (the ones Git calls \"root commits\"):

    jj log -r root()+\n

    Show some important commits (like git --simplify-by-decoration):

    jj log -r 'tags() | branches()'\n

    Show local commits leading up to the working copy, as well as descendants of those commits:

    jj log -r '(remote_branches()..@)::'\n

    Show commits authored by \"martinvonz\" and containing the word \"reset\" in the description:

    jj log -r 'author(martinvonz) & description(reset)'\n
    "},{"location":"sapling-comparison/","title":"Comparison with Sapling","text":""},{"location":"sapling-comparison/#introduction","title":"Introduction","text":"

    This document attempts to describe how jj is different from Sapling. Sapling is a VCS developed by Meta. It is a heavily modified fork of Mercurial. Because jj has copied many ideas from Mercurial, there are many similarities between the two tools, such as:

    • A user-friendly CLI
    • A \"revset\" language for selecting revisions
    • Good support for working with stacked commits, including tracking \"anonymous heads\" (no \"detached HEAD\" state like in Git) and split commands, and automatically rebasing descendant commits when you amend a commit.
    • Flexible customization of output using templates
    "},{"location":"sapling-comparison/#differences","title":"Differences","text":"

    Here is a list of some differences between jj and Sapling.

    • Working copy: When using Sapling (like most VCSs), the user explicitly tells the tool when to create a commit and which files to include. When using jj, the working copy is automatically snapshotted by every command. New files are automatically tracked and deleted files are automatically untracked. This has several advantages:

      • The working copy is effectively backed up every time you run a command.
      • No commands fail because you have changes in the working copy (\"abort: 1 conflicting file changes: ...\"). No need for sl shelve.
      • Simpler and more consistent CLI because the working copy is treated like any other commit.
    • Conflicts: Like most VCSs, Sapling requires the user to resolve conflicts before committing. jj lets you commit conflicts. Note that it's a representation of the conflict that's committed, not conflict markers (<<<<<<< etc.). This also has several advantages:

      • Merge conflicts won't prevent you from checking out another commit.
      • You can resolve the conflicts when you feel like it.
      • Rebasing descendants always succeeds. Like jj, Sapling automatically rebases, but it will fail if there are conflicts.
      • Merge commits can be rebased correctly (Sapling sometimes fails).
      • You can rebase conflicts and conflict resolutions.
    • Undo: jj's undo is powered by the operation log, which records how the repo has changed over time. Sapling has a similar feature with its MetaLog. They seem to provide similar functionality, but jj also exposes the log to the user via jj op log, so you can tell how far back you want to go back. Sapling has sl debugmetalog, but that seems to show the history of a single commit, not the whole repo's history. Thanks to jj snapshotting the working copy, it's possible to undo changes to the working copy. For example, if you jj undo a jj commit, jj diff will show the same changes as before jj commit, but if you sl undo a sl commit, the working copy will be clean.

    • Git interop: Sapling supports cloning, pushing, and pulling from a remote Git repo. jj also does, and it also supports sharing a working copy with a Git repo, so you can use jj and git interchangeably in the same repo.
    • Polish: Sapling is much more polished and feature-complete. For example, jj has no blame/annotate or bisect commands, and also no copy/rename support. Sapling also has very nice web UI called Interactive Smartlog, which lets you drag and drop commits to rebase them, among other things.
    • Forge workflow: Sapling has sl pr submit --stack, which lets you push a stack of commits as separate GitHub PRs, including setting the base branch. It only supports GitHub. jj doesn't have any direct integration with GitHub or any other forge. However, it has jj git push --change for automatically creating branches for specified commits. You have to specify each commit you want to create a branch for by using jj git push --change X --change Y ..., and you have to manually set up any base branches in GitHub's UI (or GitLab's or ...). On subsequent pushes, you can update all at once by specifying something like jj git push -r main..@ (to push all branches on the current stack of commits from where it forked from main).
    "},{"location":"templates/","title":"Templates","text":"

    Jujutsu supports a functional language to customize output of commands. The language consists of literals, keywords, operators, functions, and methods.

    A couple of jj commands accept a template via -T/--template option.

    "},{"location":"templates/#keywords","title":"Keywords","text":"

    Keywords represent objects of different types; the types are described in a follow-up section. In addition to context-specific keywords, the top-level object can be referenced as self.

    "},{"location":"templates/#commit-keywords","title":"Commit keywords","text":"

    In jj log/jj obslog templates, all 0-argument methods of the Commit type are available as keywords. For example, commit_id is equivalent to self.commit_id().

    "},{"location":"templates/#operation-keywords","title":"Operation keywords","text":"

    In jj op log templates, all 0-argument methods of the Operation type are available as keywords. For example, current_operation is equivalent to self.current_operation().

    "},{"location":"templates/#operators","title":"Operators","text":"

    The following operators are supported.

    • x.f(): Method call.
    • -x: Negate integer value.
    • !x: Logical not.
    • x && y: Logical and, short-circuiting.
    • x || y: Logical or, short-circuiting.
    • x ++ y: Concatenate x and y templates.
    "},{"location":"templates/#global-functions","title":"Global functions","text":"

    The following functions are defined.

    • fill(width: Integer, content: Template) -> Template: Fill lines at the given width.
    • indent(prefix: Template, content: Template) -> Template: Indent non-empty lines by the given prefix.
    • label(label: Template, content: Template) -> Template: Apply label to the content. The label is evaluated as a space-separated string.
    • if(condition: Boolean, then: Template[, else: Template]) -> Template: Conditionally evaluate then/else template content.
    • coalesce(content: Template...) -> Template: Returns the first non-empty content.
    • concat(content: Template...) -> Template: Same as content_1 ++ ... ++ content_n.
    • separate(separator: Template, content: Template...) -> Template: Insert separator between non-empty contents.
    • surround(prefix: Template, suffix: Template, content: Template) -> Template: Surround non-empty content with texts such as parentheses.
    "},{"location":"templates/#types","title":"Types","text":""},{"location":"templates/#boolean-type","title":"Boolean type","text":"

    No methods are defined. Can be constructed with false or true literal.

    "},{"location":"templates/#commit-type","title":"Commit type","text":"

    This type cannot be printed. The following methods are defined.

    • description() -> String
    • change_id() -> ChangeId
    • commit_id() -> CommitId
    • parents() -> List<Commit>
    • author() -> Signature
    • committer() -> Signature
    • working_copies() -> String: For multi-workspace repository, indicate working-copy commit as <workspace name>@.
    • current_working_copy() -> Boolean: True for the working-copy commit of the current workspace.
    • branches() -> List<RefName>: Local and remote branches pointing to the commit. A tracking remote branch will be included only if its target is different from the local one.
    • local_branches() -> List<RefName>: All local branches pointing to the commit.
    • remote_branches() -> List<RefName>: All remote branches pointing to the commit.
    • tags() -> List<RefName>
    • git_refs() -> List<RefName>
    • git_head() -> Option<RefName>
    • divergent() -> Boolean: True if the commit's change id corresponds to multiple visible commits.
    • hidden() -> Boolean: True if the commit is not visible (a.k.a. abandoned).
    • immutable() -> Boolean: True if the commit is included in the set of immutable commits.
    • conflict() -> Boolean: True if the commit contains merge conflicts.
    • empty() -> Boolean: True if the commit modifies no files.
    • root() -> Boolean: True if the commit is the root commit.
    "},{"location":"templates/#commitid-changeid-type","title":"CommitId / ChangeId type","text":"

    The following methods are defined.

    • .short([len: Integer]) -> String
    • .shortest([min_len: Integer]) -> ShortestIdPrefix: Shortest unique prefix.
    "},{"location":"templates/#integer-type","title":"Integer type","text":"

    No methods are defined.

    "},{"location":"templates/#list-type","title":"List type","text":"

    A list can be implicitly converted to Boolean. The following methods are defined.

    • .len() -> Integer: Number of elements in the list.
    • .join(separator: Template) -> Template: Concatenate elements with the given separator.
    • .map(|item| expression) -> ListTemplate: Apply template expression to each element. Example: parents.map(|c| c.commit_id().short())
    "},{"location":"templates/#listtemplate-type","title":"ListTemplate type","text":"

    The following methods are defined. See also the List type.

    • .join(separator: Template) -> Template
    "},{"location":"templates/#operation-type","title":"Operation type","text":"

    This type cannot be printed. The following methods are defined.

    • current_operation() -> Boolean
    • description() -> String
    • id() -> OperationId
    • tags() -> String
    • time() -> TimestampRange
    • user() -> String
    • root() -> Boolean: True if the commit is the root commit.
    "},{"location":"templates/#operationid-type","title":"OperationId type","text":"

    The following methods are defined.

    • .short([len: Integer]) -> String
    "},{"location":"templates/#option-type","title":"Option type","text":"

    An option can be implicitly converted to Boolean denoting whether the contained value is set. If set, all methods of the contained value can be invoked. If not set, an error will be reported inline on method call.

    "},{"location":"templates/#refname-type","title":"RefName type","text":"

    The following methods are defined.

    • .name() -> String: Local branch or tag name.
    • .remote() -> String: Remote name or empty if this is a local ref.
    "},{"location":"templates/#shortestidprefix-type","title":"ShortestIdPrefix type","text":"

    The following methods are defined.

    • .prefix() -> String
    • .rest() -> String
    • .upper() -> ShortestIdPrefix
    • .lower() -> ShortestIdPrefix
    "},{"location":"templates/#signature-type","title":"Signature type","text":"

    The following methods are defined.

    • .name() -> String
    • .email() -> String
    • .username() -> String
    • .timestamp() -> Timestamp
    "},{"location":"templates/#string-type","title":"String type","text":"

    A string can be implicitly converted to Boolean. The following methods are defined.

    • .len() -> Integer: Length in UTF-8 bytes.
    • .contains(needle: Template) -> Boolean
    • .first_line() -> String
    • .lines() -> List<String>: Split into lines excluding newline characters.
    • .upper() -> String
    • .lower() -> String
    • .starts_with(needle: Template) -> Boolean
    • .ends_with(needle: Template) -> Boolean
    • .remove_prefix(needle: Template) -> String: Removes the passed prefix, if present
    • .remove_suffix(needle: Template) -> String: Removes the passed suffix, if present
    • .substr(start: Integer, end: Integer) -> String: Extract substring. The start/end indices should be specified in UTF-8 bytes. Negative values count from the end of the string.
    "},{"location":"templates/#string-literals","title":"String literals","text":"

    String literals must be surrounded by double quotes (\"). The following escape sequences starting with a backslash have their usual meaning: \\\", \\\\, \\n, \\r, \\t, \\0. Other escape sequences are not supported. Any UTF-8 characters are allowed inside a string literal, with two exceptions: unescaped \"-s and uses of \\ that don't form a valid escape sequence.

    "},{"location":"templates/#template-type","title":"Template type","text":"

    Most types can be implicitly converted to Template. No methods are defined.

    "},{"location":"templates/#timestamp-type","title":"Timestamp type","text":"

    The following methods are defined.

    • .ago() -> String: Format as relative timestamp.
    • .format(format: String) -> String: Format with the specified strftime-like format string.
    • .utc() -> Timestamp: Convert timestamp into UTC timezone.
    • .local() -> Timestamp: Convert timestamp into local timezone.
    "},{"location":"templates/#timestamprange-type","title":"TimestampRange type","text":"

    The following methods are defined.

    • .start() -> Timestamp
    • .end() -> Timestamp
    • .duration() -> String
    "},{"location":"templates/#configuration","title":"Configuration","text":"

    The default templates and aliases() are defined in the [templates] and [template-aliases] sections of the config respectively. The exact definitions can be seen in the cli/src/config/templates.toml file in jj's source tree.

    New keywords and functions can be defined as aliases, by using any combination of the predefined keywords/functions and other aliases.

    For example:

    [template-aliases]\n'commit_change_ids' = '''\nconcat(\n  format_field(\"Commit ID\", commit_id),\n  format_field(\"Change ID\", commit_id),\n)\n'''\n'format_field(key, value)' = 'key ++ \": \" ++ value ++ \"\\n\"'\n
    "},{"location":"testimonials/","title":"Testimonials","text":"

    You might not be ready to make the jump to Jujutsu yet. It's understandable; new tools come with new lessons, failures, and ideas to absorb. They require practice. In order to provide some motivation, we've collected a number of real, 100% authentic testimonials \u2014 from our loving users, our silly developers \u2014 all to tip the scales and get you on our side!

    "},{"location":"testimonials/#what-the-users-have-to-say","title":"What the users have to say","text":"

    I've spent many years of my career working on version control. What I like most about Jujutsu is how it has non-obvious solutions to UX problems that we've run into in the past. What most people may not realize is that there are many novel features which all interlock to make it easy to use.

    For example, consider Jujutsu's support for automatically rebasing descendants of amended revisions. When we implemented that in Mercurial, we ran into an issue: what if there's a merge conflict? Our solution was to warn users and just not perform the auto-rebase. Now, suddenly, users have to understand that there can be old versions of the same revision visible in their log, and learn how to fix this state.

    In contrast, Jujutsu's solution is to simply make merge conflicts first-class. This is not just an improvement in general, it is also specifically an improvement for auto-rebase \u2014 users no longer have to learn about old versions of a revision unless they want to look at the obslog.

    Over and over, I'm struck by how well Jujutsu demonstrates this kind of evolved thinking, which as an experienced version control developer I deeply appreciate.

    \u2014 Rain, engineer at Oxide Computer Company, former VCS developer

    Jujutsu is amazing... I couldn't have come up with anything remotely as elegant.

    It's so rare that a solution attacks the innermost core of a problem so thoroughly, I genuinely feel blessed to be in its presence. And also a bit vindicated in not even trying to learn to use any of the tools that felt like more crutches stacked upon a sand castle

    \u2014 Anonymous user, speaking from the shadows

    It's the easiest time I've ever had learning a tool this deeply this quickly, because of the ability to experiment and undo, instead of triple-checking before trying a new scary command.

    \u2014 Scott Olson, advanced Git user and now a Jujutsu user

    I initially started to use Jujutsu for personal repos, and it has quickly gone from \"neat, let's try this more\" to \"very neat, added to my permanent config and automatically installed for new machines\".

    \u2014 Poliorcetics, on GitHub

    when i worked on the rust compiler, my job was to chain together a bunch of strange and cursed tools that broke often. jujutsu breaks about half as much, so that's pretty good i guess

    \u2014 jyn514, Rust contributor

    Jujutsu is pretty cool, you can even keep most of your existing workflows

    \u2014 Ben, who doesn't want you keeping your existing workflow

    Wait, it's not called Jujitsu?

    \u2014 Phil, Mercurial contributor (who doesn't have to learn Git, now that Jujutsu exists)

    When I heard about Jujutsu I decided to try it out before forming an opinion. Technically it never formed, because I haven't considered going back.

    \u2014 gul banana, computer programmer

    "},{"location":"testimonials/#what-the-developers-have-to-say","title":"What the developers have to say","text":"

    I've been a FOSS contributor using Git for over 16 years, and Jujutsu continues to amaze me every day. It has that sweet simplicity I was fond of in Darcs, but it boils down all my most core and fundamental workflows \u2014 developed over years of experience \u2014 into a simple set of primitives. The internal design is simple and beautiful; it looks like a database, making the implementation elegant, safe, and extensible. All this, using the same Git repositories my coworkers use.

    It's like if you found out one day that you built your entire home on a vein of rich gold. Every day I seem to find new and beautiful emergent behaviors, all adding up to a tool that is greater than the sum of its parts.

    \u2014 Austin Seipp, \"No 1. Jujutsu Fan\"

    Honestly, I implemented signing support mostly for that sweet dopamine hit that you get from the green checkmark on GitHub. Yeah.

    \u2014 Anton Bulakh, contributor and dopamine enthusiast

    I'm sometimes still surprised that navigating with jj next and jj prev works.

    \u2014 Philip Metzger, author of jj next and jj prev

    I'm surprised when it works.

    \u2014 Martin von Zweigbergk, project creator and leader

    "},{"location":"testimonials/#spread-the-word-yourself","title":"Spread the word yourself","text":"

    Are you satisfied with Jujutsu? Ready to recommend it to a Jujillion of your friends and coworkers? Great! The easiest way to help the project grow is word of mouth. So make sure to talk to them about it and show off your hip new tool. Maybe post a link to it on your other favorite tool that you love using, Slack?

    If you're not sure what to say, we hired the cheapest marketing team we could find to design a list of Pre-Approved Endorsements in their laboratory. Just copy and paste these right into a text box! Shilling for an open source project has never been easier than this.

    Jujutsu is an alright tool. I guess.

    Jujutsu is my favorite software tool of all time. I am saying this for no particular reason, definitely not because I was paid to.

    I love Jujutsu. I love Jujutsu. I love Jujutsu. I love Jujutsu. I love Jujutsu. I love Jujutsu. I love Jujutsu. I love Jujutsu.

    "},{"location":"tutorial/","title":"Tutorial","text":"

    This text assumes that the reader is familiar with Git.

    "},{"location":"tutorial/#preparation","title":"Preparation","text":"

    If you haven't already, make sure you install and configure Jujutsu.

    "},{"location":"tutorial/#cloning-a-git-repo","title":"Cloning a Git repo","text":"

    Let's start by cloning GitHub's Hello-World repo using jj:

    # Note the \"git\" before \"clone\" (there is no support for cloning native jj\n# repos yet)\n$ jj git clone https://github.com/octocat/Hello-World\nFetching into new repo in \"/tmp/tmp.O1DWMiaKd4/Hello-World\"\nWorking copy now at: kntqzsqt d7439b06 (empty) (no description set)\nParent commit      : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1\nAdded 1 files, modified 0 files, removed 0 files\n$ cd Hello-World\n

    Running jj st (short for jj status) now yields something like this:

    $ jj st\nThe working copy is clean\nWorking copy : kntqzsqt d7439b06 (empty) (no description set)\nParent commit: orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1\n

    We can see from the output above that our working copy is a real commit with a commit ID (d7439b06 in the example). When you make a change in the working copy, the working-copy commit gets automatically amended by the next jj command.

    "},{"location":"tutorial/#creating-our-first-change","title":"Creating our first change","text":"

    Now let's say we want to edit the README file in the repo to say \"Goodbye\" instead of \"Hello\". Let's start by describing the change (adding a commit message) so we don't forget what we're working on:

    # This will bring up $EDITOR (or `pico` or `Notepad` by default). Enter\n# something like \"Say goodbye\" in the editor and then save the file and close\n# the editor.\n$ jj describe\nWorking copy now at: kntqzsqt e427edcf (empty) Say goodbye\nParent commit      : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1\n

    Now make the change in the README:

    # Adjust as necessary for compatibility with your flavor of `sed`\n$ sed -i 's/Hello/Goodbye/' README\n$ jj st\nWorking copy changes:\nM README\nWorking copy : kntqzsqt 5d39e19d Say goodbye\nParent commit: orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1\n

    Note that you didn't have to tell Jujutsu to add the change like you would with git add. You actually don't even need to tell it when you add new files or remove existing files. To untrack a path, add it to your .gitignore and run jj untrack <path>.

    To see the diff, run jj diff:

    $ jj diff --git  # Feel free to skip the `--git` flag\ndiff --git a/README b/README\nindex 980a0d5f19...1ce3f81130 100644\n--- a/README\n+++ b/README\n@@ -1,1 +1,1 @@\n-Hello World!\n+Goodbye World!\n

    Jujutsu's diff format currently defaults to inline coloring of the diff (like git diff --color-words), so we used --git above to make the diff readable in this tutorial.

    As you may have noticed, the working-copy commit's ID changed both when we edited the description and when we edited the README. However, the parent commit stayed the same. Each change to the working-copy commit amends the previous version. So how do we tell Jujutsu that we are done amending the current change and want to start working on a new one? That is what jj new is for. That will create a new commit on top of your current working-copy commit. The new commit is for the working-copy changes.

    So, let's say we're now done with this change, so we create a new change:

    $ jj new\nWorking copy now at: mpqrykyp aef4df99 (empty) (no description set)\nParent commit      : kntqzsqt 5d39e19d Say goodbye\n$ jj st\nThe working copy is clean\nWorking copy : mpqrykyp aef4df99 (empty) (no description set)\nParent commit: kntqzsqt 5d39e19d Say goodbye\n

    If we later realize that we want to make further changes, we can make them in the working copy and then run jj squash. That command squashes the changes from a given commit into its parent commit. Like most commands, it acts on the working-copy commit by default. When run on the working-copy commit, it behaves very similar to git commit --amend, and jj amend is in fact an alias for jj squash.

    Alternatively, we can use jj edit <commit> to resume editing a commit in the working copy. Any further changes in the working copy will then amend the commit. Whether you choose to create a new change and squash, or to edit, typically depends on how done you are with the change; if the change is almost done, it makes sense to use jj new so you can easily review your adjustments with jj diff before running jj squash.

    "},{"location":"tutorial/#the-log-command-and-revsets","title":"The log command and \"revsets\"","text":"

    You're probably familiar with git log. Jujutsu has very similar functionality in its jj log command:

    $ jj log\n@  mpqrykyp martinvonz@google.com 2023-02-12 15:00:22.000 -08:00 aef4df99\n\u2502  (empty) (no description set)\n\u25c9  kntqzsqt martinvonz@google.com 2023-02-12 14:56:59.000 -08:00 5d39e19d\n\u2502  Say goodbye\n\u2502 \u25c9  tpstlust support+octocat@github.com 2018-05-10 12:55:19.000 -05:00 octocat-patch-1@origin b1b3f972\n\u251c\u2500\u256f  sentence case\n\u2502 \u25c9  kowxouwz octocat@nowhere.com 2014-06-10 15:22:26.000 -07:00 test@origin b3cbd5bb\n\u251c\u2500\u256f  Create CONTRIBUTING.md\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2502  (empty) Merge pull request #6 from Spaceghost/patch-1\n~\n

    The @ indicates the working-copy commit. The first ID on a line (e.g. \"mpqrykyp\" above) is the \"change ID\", which is an ID that follows the commit as it's rewritten (similar to Gerrit's Change-Id). The second ID is the commit ID, which changes when you rewrite the commit. You can give either ID to commands that take revisions as arguments. We will generally prefer change IDs because they stay the same when the commit is rewritten.

    By default, jj log lists your local commits, with some remote commits added for context. The ~ indicates that the commit has parents that are not included in the graph. We can use the --revisions/-r flag to select a different set of revisions to list. The flag accepts a \"revset\", which is an expression in a simple language for specifying revisions. For example, @ refers to the working-copy commit, root() refers to the root commit, branches() refers to all commits pointed to by branches. We can combine expressions with | for union, & for intersection and ~ for difference. For example:

    $ jj log -r '@ | root() | branches()'\n@  mpqrykyp martinvonz@google.com 2023-02-12 15:00:22.000 -08:00 aef4df99\n\u2577  (empty) (no description set)\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2577  (empty) Merge pull request #6 from Spaceghost/patch-1\n\u25c9  zzzzzzzz root() 00000000\n

    The 00000000 commit (change ID zzzzzzzz) is a virtual commit that's called the \"root commit\". It's the root commit of every repo. The root() function in the revset matches it.

    There are also operators for getting the parents (foo-), children (foo+), ancestors (::foo), descendants (foo::), DAG range (foo::bar, like git log --ancestry-path), range (foo..bar, same as Git's). See the revset documentation for all revset operators and functions.

    "},{"location":"tutorial/#conflicts","title":"Conflicts","text":"

    Now let's see how Jujutsu deals with merge conflicts. We'll start by making some commits. We use jj new with the --message/-m option to set change descriptions (commit messages) right away.

    # Start creating a chain of commits off of the `master` branch\n$ jj new master -m A; echo a > file1\nWorking copy now at: nuvyytnq 00a2aeed (empty) A\nParent commit      : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1\nAdded 0 files, modified 1 files, removed 0 files\n$ jj new -m B1; echo b1 > file1\nWorking copy now at: ovknlmro 967d9f9f (empty) B1\nParent commit      : nuvyytnq 5dda2f09 A\n$ jj new -m B2; echo b2 > file1\nWorking copy now at: puqltutt 8ebeaffa (empty) B2\nParent commit      : ovknlmro 7d7c6e6b B1\n$ jj new -m C; echo c > file2\nWorking copy now at: qzvqqupx 62a3c6d3 (empty) C\nParent commit      : puqltutt daa6ffd5 B2\n$ jj log\n@  qzvqqupx martinvonz@google.com 2023-02-12 15:07:41.946 -08:00 2370ddf3\n\u2502  C\n\u25c9  puqltutt martinvonz@google.com 2023-02-12 15:07:33.000 -08:00 daa6ffd5\n\u2502  B2\n\u25c9  ovknlmro martinvonz@google.com 2023-02-12 15:07:24.000 -08:00 7d7c6e6b\n\u2502  B1\n\u25c9  nuvyytnq martinvonz@google.com 2023-02-12 15:07:05.000 -08:00 5dda2f09\n\u2502  A\n\u2502 \u25c9  kntqzsqt martinvonz@google.com 2023-02-12 14:56:59.000 -08:00 5d39e19d\n\u251c\u2500\u256f  Say goodbye\n\u2502 \u25c9  tpstlust support+octocat@github.com 2018-05-10 12:55:19.000 -05:00 octocat-patch-1@origin b1b3f972\n\u251c\u2500\u256f  sentence case\n\u2502 \u25c9  kowxouwz octocat@nowhere.com 2014-06-10 15:22:26.000 -07:00 test@origin b3cbd5bb\n\u251c\u2500\u256f  Create CONTRIBUTING.md\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2502  (empty) Merge pull request #6 from Spaceghost/patch-1\n~\n

    We now have a few commits, where A, B1, and B2 modify the same file, while C modifies a different file. Let's now rebase B2 directly onto A. We use the --source/-s option on the change ID of B2, and --destination/-d option on A.

    $ jj rebase -s puqltutt -d nuvyytnq  # Replace the IDs by what you have for B2 and A\nRebased 2 commits\nNew conflicts appeared in these commits:\n  qzvqqupx 1978b534 (conflict) C\n  puqltutt f7fb5943 (conflict) B2\nTo resolve the conflicts, start by updating to the first one:\n  jj new puqltuttzvly\nThen use `jj resolve`, or edit the conflict markers in the file directly.\nOnce the conflicts are resolved, you may want inspect the result with `jj diff`.\nThen run `jj squash` to move the resolution into the conflicted commit.\nWorking copy now at: qzvqqupx 1978b534 (conflict) C\nParent commit      : puqltutt f7fb5943 (conflict) B2\nAdded 0 files, modified 1 files, removed 0 files\n$ jj log\n@  qzvqqupx martinvonz@google.com 2023-02-12 15:08:33.000 -08:00 1978b534 conflict\n\u2502  C\n\u25c9  puqltutt martinvonz@google.com 2023-02-12 15:08:33.000 -08:00 f7fb5943 conflict\n\u2502  B2\n\u2502 \u25c9  ovknlmro martinvonz@google.com 2023-02-12 15:07:24.000 -08:00 7d7c6e6b\n\u251c\u2500\u256f  B1\n\u25c9  nuvyytnq martinvonz@google.com 2023-02-12 15:07:05.000 -08:00 5dda2f09\n\u2502  A\n\u2502 \u25c9  kntqzsqt martinvonz@google.com 2023-02-12 14:56:59.000 -08:00 5d39e19d\n\u251c\u2500\u256f  Say goodbye\n\u2502 \u25c9  tpstlust support+octocat@github.com 2018-05-10 12:55:19.000 -05:00 octocat-patch-1@origin b1b3f972\n\u251c\u2500\u256f  sentence case\n\u2502 \u25c9  kowxouwz octocat@nowhere.com 2014-06-10 15:22:26.000 -07:00 test@origin b3cbd5bb\n\u251c\u2500\u256f  Create CONTRIBUTING.md\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2502  (empty) Merge pull request #6 from Spaceghost/patch-1\n~\n

    There are several things worth noting here. First, the jj rebase command said \"Rebased 2 commits\". That's because we asked it to rebase commit B2 with the -s option, which also rebases descendants (commit C in this case). Second, because B2 modified the same file (and word) as B1, rebasing it resulted in conflicts, as the output indicates. Third, the conflicts did not prevent the rebase from completing successfully, nor did it prevent C from getting rebased on top.

    Now let's resolve the conflict in B2. We'll do that by creating a new commit on top of B2. Once we've resolved the conflict, we'll squash the conflict resolution into the conflicted B2. That might look like this:

    $ jj new puqltutt  # Replace the ID by what you have for B2\nWorking copy now at: zxoosnnp c7068d1c (conflict) (empty) (no description set)\nParent commit      : puqltutt f7fb5943 (conflict) B2\nAdded 0 files, modified 0 files, removed 1 files\n$ jj st\nThe working copy is clean\nThere are unresolved conflicts at these paths:\nfile1    2-sided conflict\nWorking copy : zxoosnnp c7068d1c (conflict) (empty) (no description set)\nParent commit: puqltutt f7fb5943 (conflict) B2\n$ cat file1\n<<<<<<<\n%%%%%%%\n-b1\n+a\n+++++++\nb2\n>>>>>>>\n$ echo resolved > file1\n$ jj squash\nRebased 1 descendant commits\nExisting conflicts were resolved or abandoned from these commits:\n  qzvqqupx hidden 1978b534 (conflict) C\n  puqltutt hidden f7fb5943 (conflict) B2\nWorking copy now at: ntxxqymr e3c279cc (empty) (no description set)\nParent commit      : puqltutt 2c7a658e B2\n$ jj log\n@  ntxxqymr martinvonz@google.com 2023-02-12 19:34:09.000 -08:00 e3c279cc\n\u2502  (empty) (no description set)\n\u2502 \u25c9  qzvqqupx martinvonz@google.com 2023-02-12 19:34:09.000 -08:00 b9da9d28\n\u251c\u2500\u256f  C\n\u25c9  puqltutt martinvonz@google.com 2023-02-12 19:34:09.000 -08:00 2c7a658e\n\u2502  B2\n\u2502 \u25c9  ovknlmro martinvonz@google.com 2023-02-12 15:07:24.000 -08:00 7d7c6e6b\n\u251c\u2500\u256f  B1\n\u25c9  nuvyytnq martinvonz@google.com 2023-02-12 15:07:05.000 -08:00 5dda2f09\n\u2502  A\n\u2502 \u25c9  kntqzsqt martinvonz@google.com 2023-02-12 14:56:59.000 -08:00 5d39e19d\n\u251c\u2500\u256f  Say goodbye\n\u2502 \u25c9  tpstlust support+octocat@github.com 2018-05-10 12:55:19.000 -05:00 octocat-patch-1@origin b1b3f972\n\u251c\u2500\u256f  sentence case\n\u2502 \u25c9  kowxouwz octocat@nowhere.com 2014-06-10 15:22:26.000 -07:00 test@origin b3cbd5bb\n\u251c\u2500\u256f  Create CONTRIBUTING.md\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2502  (empty) Merge pull request #6 from Spaceghost/patch-1\n~\n

    Note that commit C automatically got rebased on top of the resolved B2, and that C is also resolved (since it modified only a different file).

    By the way, if we want to get rid of B1 now, we can run jj abandon ovknlmro. That will hide the commit from the log output and will rebase any descendants to its parent.

    "},{"location":"tutorial/#the-operation-log","title":"The operation log","text":"

    Jujutsu keeps a record of all changes you've made to the repo in what's called the \"operation log\". Use the jj op (short for jj operation) family of commands to interact with it. To list the operations, use jj op log:

    $ jj op log\n@  d3b77addea49 martinvonz@vonz.svl.corp.google.com 3 minutes ago, lasted 3 milliseconds\n\u2502  squash commit 63874fe6c4fba405ffc38b0dd926f03b715cf7ef\n\u2502  args: jj squash\n\u25c9  6fc1873c1180 martinvonz@vonz.svl.corp.google.com 3 minutes ago, lasted 1 milliseconds\n\u2502  snapshot working copy\n\u2502  args: jj squash\n\u25c9  ed91f7bcc1fb martinvonz@vonz.svl.corp.google.com 6 minutes ago, lasted 1 milliseconds\n\u2502  new empty commit\n\u2502  args: jj new puqltutt\n\u25c9  367400773f87 martinvonz@vonz.svl.corp.google.com 12 minutes ago, lasted 3 milliseconds\n\u2502  rebase commit daa6ffd5a09a8a7d09a65796194e69b7ed0a566d and descendants\n\u2502  args: jj rebase -s puqltutt -d nuvyytnq\n[many more lines]\n

    The most useful command is jj undo (alias for jj op undo), which will undo an operation. By default, it will undo the most recent operation. Let's try it:

    $ jj undo\nNew conflicts appeared in these commits:\n  qzvqqupx 1978b534 (conflict) C\n  puqltutt f7fb5943 (conflict) B2\nTo resolve the conflicts, start by updating to the first one:\n  jj new puqltuttzvly\nThen use `jj resolve`, or edit the conflict markers in the file directly.\nOnce the conflicts are resolved, you may want inspect the result with `jj diff`.\nThen run `jj squash` to move the resolution into the conflicted commit.\nWorking copy now at: zxoosnnp 63874fe6 (no description set)\nParent commit      : puqltutt f7fb5943 (conflict) B2\n$ jj log\n@  zxoosnnp martinvonz@google.com 2023-02-12 19:34:09.000 -08:00 63874fe6\n\u2502  (no description set)\n\u2502 \u25c9  qzvqqupx martinvonz@google.com 2023-02-12 15:08:33.000 -08:00 1978b534 conflict\n\u251c\u2500\u256f  C\n\u25c9  puqltutt martinvonz@google.com 2023-02-12 15:08:33.000 -08:00 f7fb5943 conflict\n\u2502  B2\n\u2502 \u25c9  ovknlmro martinvonz@google.com 2023-02-12 15:07:24.000 -08:00 7d7c6e6b\n\u251c\u2500\u256f  B1\n\u25c9  nuvyytnq martinvonz@google.com 2023-02-12 15:07:05.000 -08:00 5dda2f09\n\u2502  A\n\u2502 \u25c9  kntqzsqt martinvonz@google.com 2023-02-12 14:56:59.000 -08:00 5d39e19d\n\u251c\u2500\u256f  Say goodbye\n\u2502 \u25c9  tpstlust support+octocat@github.com 2018-05-10 12:55:19.000 -05:00 octocat-patch-1@origin b1b3f972\n\u251c\u2500\u256f  sentence case\n\u2502 \u25c9  kowxouwz octocat@nowhere.com 2014-06-10 15:22:26.000 -07:00 test@origin b3cbd5bb\n\u251c\u2500\u256f  Create CONTRIBUTING.md\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2502  (empty) Merge pull request #6 from Spaceghost/patch-1\n~\n

    As you can perhaps see, that undid the jj squash invocation we used for squashing the conflict resolution into commit B2 earlier. Notice that it also updated the working copy.

    You can also view the repo the way it looked after some earlier operation. For example, if you want to see jj log output right after the jj rebase operation, try jj log --at-op=367400773f87 but use the hash from your own jj op log.

    "},{"location":"tutorial/#moving-content-changes-between-commits","title":"Moving content changes between commits","text":"

    You have already seen how jj squash can combine the changes from two commits into one. There are several other commands for changing the contents of existing commits.

    We'll need some more complex content to test these commands, so let's create a few more commits:

    $ jj new master -m abc; printf 'a\\nb\\nc\\n' > file\nWorking copy now at: ztqrpvnw f94e49cf (empty) abc\nParent commit      : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1\nAdded 0 files, modified 0 files, removed 1 files\n$ jj new -m ABC; printf 'A\\nB\\nc\\n' > file\nWorking copy now at: kwtuwqnm 6f30cd1f (empty) ABC\nParent commit      : ztqrpvnw 51002261 ab\n$ jj new -m ABCD; printf 'A\\nB\\nC\\nD\\n' > file\nWorking copy now at: mrxqplyk a6749154 (empty) ABCD\nParent commit      : kwtuwqnm 30aecc08 ABC\n$ jj log -r master::@\n@  mrxqplyk martinvonz@google.com 2023-02-12 19:38:21.000 -08:00 b98c607b\n\u2502  ABCD\n\u25c9  kwtuwqnm martinvonz@google.com 2023-02-12 19:38:12.000 -08:00 30aecc08\n\u2502  ABC\n\u25c9  ztqrpvnw martinvonz@google.com 2023-02-12 19:38:03.000 -08:00 51002261\n\u2502  abc\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2502  (empty) Merge pull request #6 from Spaceghost/patch-1\n~\n

    We \"forgot\" to capitalize \"c\" in the second commit when we capitalized the other letters. We then fixed that in the third commit when we also added \"D\". It would be cleaner to move the capitalization of \"c\" into the second commit. We can do that by running jj squash with the --interactive/-i option on the third commit. Remember that jj squash moves all the changes from one commit into its parent. jj squash -i moves only part of the changes into its parent. Now try that:

    $ jj squash -i\nUsing default editor ':builtin'; you can change this by setting ui.diff-editor\nWorking copy now at: mrxqplyk 52a6c7fd ABCD\nParent commit      : kwtuwqnm 643061ac ABC\n

    That will bring up the built-in diff editor with a diff of the changes in the \"ABCD\" commit. If you prefer another diff editor, you can configure ui.diff-editor instead. Modify the right side of the diff to have the desired end state in \"ABC\" by removing the \"D\" line. Then save the changes and close Meld. If we look at the diff of the second commit, we now see that all three lines got capitalized:

    $ jj diff -r @-\nModified regular file file:\n   1    1: aA\n   2    2: bB\n   3    3: cC\n

    The child change (\"ABCD\" in our case) will have the same content state after the jj squash command. That means that you can move any changes you want into the parent change, even if they touch the same word, and it won't cause any conflicts.

    Let's try one final command for changing the contents of an exiting commit. That command is jj diffedit, which lets you edit the contents of a commit without checking it out.

    $ jj diffedit -r @-\nUsing default editor ':builtin'; you can change this by setting ui.diff-editor\nCreated kwtuwqnm 70985eaa (empty) ABC\nRebased 1 descendant commits\nNew conflicts appeared in these commits:\n  mrxqplyk 1c72cd50 (conflict) ABCD\nTo resolve the conflicts, start by updating to it:\n  jj new mrxqplykmyqv\nThen use `jj resolve`, or edit the conflict markers in the file directly.\nOnce the conflicts are resolved, you may want inspect the result with `jj diff`.\nThen run `jj squash` to move the resolution into the conflicted commit.\nWorking copy now at: mrxqplyk 1c72cd50 (conflict) ABCD\nParent commit      : kwtuwqnm 70985eaa (empty) ABC\nAdded 0 files, modified 1 files, removed 0 files\n

    In the diff editor, edit the right side by e.g. adding something to the first line. Press 'c' to save the changes and close it. You can now inspect the rewritten commit with jj diff -r @- again and you should see your addition to the first line. Unlike jj squash -i, which left the content state of the commit unchanged, jj diffedit (typically) results in a different state, which means that descendant commits may have conflicts.

    Other commands for rewriting contents of existing commits are jj split, jj unsquash -i. Now that you've seen how jj squash -i and jj diffedit work, you can hopefully figure out how those work (with the help of the instructions in the diff).

    "},{"location":"windows/","title":"Working on Windows","text":"

    Jujutsu works the same on all platforms, but there are some caveats that Windows users should be aware of.

    "},{"location":"windows/#line-endings-are-not-converted","title":"Line endings are not converted","text":"

    Jujutsu does not currently honor .gitattributes and does not have a setting like Git's core.autocrlf. This means that line endings will be checked out exactly as they are committed and committed exactly as authored. This is true on all platforms, but Windows users are most likely to miss CRLF conversion.

    If your Git repository expects Windows users to have core.autocrlf set to true, then the files are committed with LF line endings but are checked out with CRLF line endings. Jujutsu doesn't understand this and will convert the committed line endings to CRLF.

    After creating a colocated repository on Windows, you most likely want to set core.autocrlf to input, then jj abandon to convert all files on disk to LF line endings:

    PS> git config core.autocrlf input\n\n# Abandoning the working copy will cause Jujutsu to overwrite all files with\n# CRLF line endings with the line endings they are committed with, probably LF\nPS> jj abandon\n

    This setting ensures Git will check out files with LF line endings without converting them to CRLF. You'll want to make sure any tooling you use, especially IDEs, preserve LF line endings.

    "},{"location":"windows/#pagination","title":"Pagination","text":"

    Pagination is disabled by default on Windows because Windows doesn't ship with a usable pager.

    If you have Git installed, you can use Git's pager and re-enable pagination:

    PS> jj config set --user ui.pager '[\"C:\\\\Program Files\\\\Git\\\\usr\\\\bin\\\\less.exe\", \"-FRX\"]'\nPS> jj config set --user ui.paginate auto\n
    "},{"location":"windows/#typing-in-powershell","title":"Typing @ in PowerShell","text":"

    PowerShell uses @ as part the array sub-expression operator, so it often needs to be escaped or quoted in commands:

    PS> jj log -r `@\nPS> jj log -r '@'\n

    One solution is to create a revset alias. For example, to make HEAD an alias for @:

    PS> jj config set --user revset-aliases.HEAD '@'\nPS> jj log -r HEAD\n
    "},{"location":"windows/#wsl-sets-the-execute-bit-on-all-files","title":"WSL sets the execute bit on all files","text":"

    When viewing a Windows drive from WSL (via /mnt/c or a similar path), Windows exposes all files with the execute bit set. Since Jujutsu automatically records changes to the working copy, this sets the execute bit on all files committed in your repository.

    If you only need to access the repository in WSL, the best solution is to clone the repository in the Linux file system (for example, in ~/my-repo).

    If you need to use the repository in both WSL and Windows, one solution is to create a workspace in the Linux file system:

    PS> jj workspace add --name wsl ~/my-repo\n

    Then only use the ~/my-repo workspace from Linux.

    "},{"location":"windows/#symbolic-link-support","title":"Symbolic link support","text":"

    jj supports symlinks on Windows only when they are enabled by the operating system. This requires Windows 10 version 14972 or higher, as well as Developer Mode. If those conditions are not satisfied, jj will materialize symlinks as ordinary files.

    For colocated repositories, Git support must also be enabled using the git config option core.symlinks=true.

    "},{"location":"working-copy/","title":"Working copy","text":""},{"location":"working-copy/#introduction","title":"Introduction","text":"

    The working copy is where the current working-copy commit's files are written so you can interact with them. It also where files are read from in order to create new commits (though there are many other ways of creating new commits).

    Unlike most other VCSs, Jujutsu will automatically create commits from the working-copy contents when they have changed. Most jj commands you run will commit the working-copy changes if they have changed. The resulting revision will replace the previous working-copy revision.

    Also unlike most other VCSs, added files are implicitly tracked. That means that if you add a new file to the working copy, it will be automatically committed once you run e.g. jj st. Similarly, if you remove a file from the working copy, it will implicitly be untracked. To untrack a file while keeping it in the working copy, first make sure it's ignored and then run jj untrack <path>.

    "},{"location":"working-copy/#conflicts","title":"Conflicts","text":"

    When you check out a commit with conflicts, those conflicts need to be represented in the working copy somehow. However, the file system doesn't understand conflicts. Jujutsu's solution is to add conflict markers to conflicted files when it writes them to the working copy. It also keeps track of the (typically 3) different parts involved in the conflict. Whenever it scans the working copy thereafter, it parses the conflict markers and recreates the conflict state from them. You can resolve conflicts by replacing the conflict markers by the resolved text. You don't need to resolve all conflicts at once. You can even resolve part of a conflict by updating the different parts of the conflict marker.

    To resolve conflicts in a commit, use jj new <commit> to create a working-copy commit on top. You would then have the same conflicts in the working-copy commit. Once you have resolved the conflicts, you can inspect the conflict resolutions with jj diff. Then run jj squash to move the conflict resolutions into the conflicted commit. Alternatively, you can edit the commit with conflicts directly in the working copy by using jj edit <commit>. The main disadvantage of that is that it's harder to inspect the conflict resolutions.

    With the jj resolve command, you can use an external merge tool to resolve conflicts that have 2 sides and a base. There is not yet a good way of resolving conflicts between directories, files, and symlinks (https://github.com/martinvonz/jj/issues/19). You can use jj restore to choose one side of the conflict, but there's no way to even see where the involved parts came from.

    "},{"location":"working-copy/#ignored-files","title":"Ignored files","text":"

    You probably don't want build outputs and temporary files to be under version control. You can tell Jujutsu to not automatically track certain files by using .gitignore files (there's no such thing as .jjignore yet). See https://git-scm.com/docs/gitignore for details about the format. .gitignore files are supported in any directory in the working copy, as well as in $HOME/.gitignore and $GIT_DIR/info/exclude.

    "},{"location":"working-copy/#workspaces","title":"Workspaces","text":"

    You can have multiple working copies backed by a single repo. Use jj workspace add to create a new working copy. The working copy will have a .jj/ directory linked to the main repo. The working copy and the .jj/ directory together is called a \"workspace\". Each workspace can have a different commit checked out.

    Having multiple workspaces can be useful for running long-running tests in a one while you continue developing in another, for example. If needed, jj workspace root prints the root path of the current workspace.

    When you're done using a workspace, use jj workspace forget to make the repo forget about it. The files can be deleted from disk separately (either before or after).

    "},{"location":"working-copy/#stale-working-copy","title":"Stale working copy","text":"

    When you modify workspace A's working-copy commit from workspace B, workspace A's working copy will become stale. By \"stale\", we mean that the files in the working copy don't match the desired commit indicated by the @ symbol in jj log. When that happens, use jj workspace update-stale to update the files in the working copy.

    "},{"location":"design/git-submodule-storage/","title":"Git submodule storage","text":""},{"location":"design/git-submodule-storage/#objective","title":"Objective","text":"

    Decide what approach(es) to Git submodule storage we should pursue. The decision will be recorded in ./git-submodules.md.

    "},{"location":"design/git-submodule-storage/#use-cases-to-consider","title":"Use cases to consider","text":"

    The submodule storage format should support the workflows specified in the submodules roadmap. It should be obvious how \"Phase 1\" requirements will be supported, and we should have an idea of how \"Phases 2,3,X\" might be supported.

    Notable use cases and workflows are noted below.

    "},{"location":"design/git-submodule-storage/#fetching-submodule-commits","title":"Fetching submodule commits","text":"

    Git's protocol is designed for communicating between copies of the same repository. Notably, a Git fetch calculates the list of required objects by performing reachability checks between the refs on the local and the remote side. We should expect that this will only work well if the submodule repository is stored as a local Git repository.

    Rolling our own Git fetch is too complex to be worth the effort.

    "},{"location":"design/git-submodule-storage/#jj-op-restore-and-operation-log-format","title":"\"jj op restore\" and operation log format","text":"

    We want jj op restore to restore to an \"expected\" state in the submodule. There is a potential distinction between running jj op restore in the superproject vs in the submodule, and the expected behavior may be different in each case, e.g. in the superproject, it might be enough to restore the submodule working copy, but in the submodule, refs also need to be restored.

    Currently, the operation log only references objects and refs in the superproject, so it is likely that proposed approaches will need to extend this format. It is also worth considering that submodules may be added, updated or removed in superproject commits, thus the list of submodules is likely to change over the repository's lifetime.

    "},{"location":"design/git-submodule-storage/#nested-submodules","title":"Nested submodules","text":"

    Git submodules may contain submodules themselves, so our chosen storage schemes should support that.

    We should consider limiting the recursion depth to avoid nasty edge cases (e.g. cyclical submodules.) that might surprise users.

    "},{"location":"design/git-submodule-storage/#supporting-future-extensions","title":"Supporting future extensions","text":"

    There are certain extensions we may want to make in the future, but we don't have a timeline for them today. Proposed approaches should take these extensions into account (e.g. the approach should be theoretically extensible), but a full proposal for implementing them is not necessary.

    These extensions are:

    • Non-git subrepos
    • Colocated Git repos
    • The superproject using a non-git backend
    "},{"location":"design/git-submodule-storage/#proposed-design","title":"Proposed design","text":"

    Git submodules will be stored as full jj repos. In the code, jj commands will only interact with the submodule's repo as an entire unit, e.g. it cannot query the submodule's commit backend directly. A well-abstracted submodule will extend well to non-git backends and non-git subrepos.

    The main challenge with this approach is that the submodule repo can be in a state that is internally valid (when considering only the submodule's repo), but invalid when considering the superproject-submodule system. This will be managed by requiring all submodule interactions go through the superproject so that superproject-submodule coordination can occur. For example, jj will not allow the user to work on the submodule's repo without going through the superproject (unlike Git).

    The notable workflows could be addressed like so:

    "},{"location":"design/git-submodule-storage/#fetching-submodule-commits_1","title":"Fetching submodule commits","text":"

    The submodule would fetch using the equivalent of jj git fetch. It remains to be decided how a \"recursive\" fetch should work, especially if a newly fetched superproject commit references an unfetched submodule commit. A reasonable approximation would be to fetch all branches in the submodule, and then, if the submodule commit is still missing, gracefully handle it.

    "},{"location":"design/git-submodule-storage/#jj-op-restore-and-operation-log-format_1","title":"\"jj op restore\" and operation log format","text":"

    As full repos, each submodule will have its own operation log. We will continue to use the existing operation log format, where each operation log tracks their own repo's commits. As commands are run in the superproject, corresponding commands will be run in the submodule as necessary, e.g. checking out a superproject commit will cause a submodule commit to also be checked out.

    Since there is no association between a superproject operation and a submodule operation, jj op restore in the superproject will not restore the submodule to a previous operation. Instead, the appropriate submodule operation(s) will be created. This is sufficient to preserve the superproject-submodule relationship; it precludes \"recursive\" restore (e.g. restoring branches in the superproject and submodules) but it seems unlikely that we will need such a thing.

    "},{"location":"design/git-submodule-storage/#nested-submodules_1","title":"Nested submodules","text":"

    Since submodules are full repos, they can contain submodules themselves. Nesting is unlikely to complicate any of the core features, since the top-level superproject/submodule relationship is almost identical to the submodule/nested submodule relationship.

    "},{"location":"design/git-submodule-storage/#extending-to-colocated-git-repos","title":"Extending to colocated Git repos","text":"

    Git expects submodules to be in .git/modules, so it will not understand this storage format. To support colocated Git repos, we will have to change Git to allow a submodule's gitdir to be in an alternate location (e.g. we could add a new submodule.<name>.gitdir config option). This is a simple change, so it should be feasible.

    "},{"location":"design/git-submodule-storage/#alternatives-considered","title":"Alternatives considered","text":""},{"location":"design/git-submodule-storage/#git-repos-in-the-main-git-backend","title":"Git repos in the main Git backend","text":"

    Since the Git backend contains a Git repository, an 'obvious' default would be to store them in the Git superproject the same way Git does, i.e. in .git/modules. Since Git submodules are full repositories that can have submodules, this storage scheme naturally extends to nested submodules.

    Most of the work in storing submodules and querying them would be well-isolated to the Git backend, which gives us a lot of flexibility to make changes without affecting the rest of jj. However, the operation log will need a significant rework since it isn't designed to reference submodules, and handling edge cases (e.g. a submodule being added/removed, nested submodules) will be tricky.

    This is rejected because handling that operation log complexity isn't worth it when very little of the work extends to non-Git backends.

    "},{"location":"design/git-submodule-storage/#store-git-submodules-as-alternate-git-backends","title":"Store Git submodules as alternate Git backends","text":"

    Teach jj to use multiple commit backends and store Git submodules as Git backends. Since submodules are separate from the 'main' backend, a repository can use whatever backend it wants as its 'main' one, while still having Git submodules in the 'alternate' Git backends.

    This approach extends fairly well to non-Git submodules (which would be stored in non-Git commit backends). However, this requires significantly reworking the operation log to account for multiple commit backends. It is also not clear how nested submodules will be supported since there isn't an obvious way to represent a nested submodule's relationship to its superproject.

    "},{"location":"design/git-submodules/","title":"Git submodules","text":"

    This is an aspirational document that describes how jj will support Git submodules. Readers are assumed to have some familiarity with Git and Git submodules.

    This document is a work in progress; submodules are a big feature, and relevant details will be filled in incrementally.

    "},{"location":"design/git-submodules/#objective","title":"Objective","text":"

    This proposal aims to replicate the workflows users are used to with Git submodules, e.g.:

    • Cloning submodules
    • Making new submodule commits and updating the superproject
    • Fetching and pushing updates to the submodule's remote
    • Viewing submodule history

    When it is convenient, this proposal will also aim to make submodules easier to use than Git's implementation.

    "},{"location":"design/git-submodules/#non-goals","title":"Non-goals","text":"
    • Non-Git 'submodules' (e.g. native jj submodules, other VCSes)
    • Non-Git backends (e.g. Google internal backend)
    • Changing how Git submodules are implemented in Git
    "},{"location":"design/git-submodules/#background","title":"Background","text":"

    We mainly want to support Git submodules for feature parity, since Git submodules are a standard feature in Git and are popular enough that we have received user requests for them. Secondarily (and distantly so), Git submodules are notoriously difficult to use, so there is an opportunity to improve the UX over Git's implementation.

    "},{"location":"design/git-submodules/#intro-to-git-submodules","title":"Intro to Git Submodules","text":"

    Git submodules are a feature of Git that allow a repository (submodule) to be embedded inside another repository (the superproject). Notably, a submodule is a full repository, complete with its own index, object store and ref store. It can be interacted with like any other repository, regardless of the superproject.

    In a superproject commit, submodule information is captured in two places:

    • A gitlink entry in the commit's tree, where the value of the gitlink entry is the submodule commit id. This tells Git what to populate in the working tree.

    • A top level .gitmodules file. This file is in Git's config syntax and entries take the form submodule.<submodule-name>.*. These include many settings about the submodules, but most importantly:

      • submodule<submodule-name>.path contains the path from the root of the tree to the gitlink being described.

      • submodule<submodule-name>.url contains the url to clone the submodule from.

    In the working tree, Git notices the presence of a submodule by the .git entry (signifying the root of a Git repository working tree). This is either the submodule's actual Git directory (an \"old-form\" submodule), or a .git file pointing to <superproject-git-directory>/modules/<submodule-name>. The latter is sometimes called the \"absorbed form\", and is Git's preferred mode of operation.

    "},{"location":"design/git-submodules/#roadmap","title":"Roadmap","text":"

    Git submodules should be implemented in an order that supports an increasing set of workflows, with the goal of getting feedback early and often. When support is incomplete, jj should not crash, but instead provide fallback behavior and warn the user where needed.

    The goal is to land good support for pure Jujutsu repositories, while colocated repositories will be supported when convenient.

    This section should be treated as a set of guidelines, not a strict order of work.

    "},{"location":"design/git-submodules/#phase-1-readonly-submodules","title":"Phase 1: Readonly submodules","text":"

    This includes work that inspects submodule contents but does not create new objects in the submodule. This requires a way to store submodules in a jj repository that supports readonly operations.

    "},{"location":"design/git-submodules/#outcomes","title":"Outcomes","text":"
    • Submodules can be cloned anew
    • New submodule commits can be fetched
    • Submodule history and branches can be viewed
    • Submodule contents are populated in the working copy
    • Superproject gitlink can be updated to an existing submodule commit
    • Conflicts in the superproject gitlink can be resolved to an existing submodule commit
    "},{"location":"design/git-submodules/#phase-2-snapshotting-new-changes","title":"Phase 2: Snapshotting new changes","text":"

    This allows a user to write new contents to a submodule and its remote.

    "},{"location":"design/git-submodules/#outcomes_1","title":"Outcomes","text":"
    • Changes in the working copy can be recorded in a submodule commit
    • Submodule branches can be modified
    • Submodules and their branches can be pushed to their remote
    "},{"location":"design/git-submodules/#phase-3-mergingrebasingconflicts","title":"Phase 3: Merging/rebasing/conflicts","text":"

    This allows merging and rebasing of superproject commits in a content-aware way (in contrast to Git, where only the gitlink commit ids are compared), as well as workflows that make resolving conflicts easy and sensible.

    This can be done in tandem with Phase 2, but will likely require a significant amount of design work on its own.

    "},{"location":"design/git-submodules/#outcomes_2","title":"Outcomes","text":"
    • Merged/rebased submodules result in merged/rebased working copy content
    • Merged/rebased working copy content can be committed, possibly by creating sensible merged/rebased submodule commits
    • Merge/rebase between submodule and non-submodule gives a sensible result
    • Merge/rebase between submodule A and submodule B gives a sensible result
    "},{"location":"design/git-submodules/#phase-an-ideal-world","title":"Phase ?: An ideal world","text":"

    I.e. outcomes we would like to see if there were no constraints whatsoever.

    • Rewriting submodule commits rewrites descendants correctly and updates superproject gitlinks.
    • Submodule conflicts automatically resolve to the 'correct' submodule commits, e.g. a merge between superproject commits creating a merge of the submodule commits.
    • Nested submodules are as easy to work with as non-nested submodules.
    • The operation log captures changes in the submodule.
    "},{"location":"design/git-submodules/#design","title":"Design","text":""},{"location":"design/git-submodules/#guiding-principles","title":"Guiding principles","text":"

    TODO

    "},{"location":"design/git-submodules/#storing-submodules","title":"Storing submodules","text":"

    Possible approaches under discussion. See ./git-submodule-storage.md.

    "},{"location":"design/git-submodules/#snapshotting-new-submodule-changes","title":"Snapshotting new submodule changes","text":"

    TODO

    "},{"location":"design/git-submodules/#mergingrebasing-with-submodules","title":"Merging/rebasing with submodules","text":"

    TODO

    "},{"location":"design/run/","title":"Introducing JJ run","text":"

    Authors: Philip Metzger, Martin von Zweigberk, Danny Hooper, Waleed Khan

    Initial Version, 10.12.2022 (view full history here)

    Summary: This Document documents the design of a new run command for Jujutsu which will be used to seamlessly integrate with build systems, linters and formatters. This is achieved by running a user-provided command or script across multiple revisions. For more details, read the Use-Cases of jj run.

    "},{"location":"design/run/#preface","title":"Preface","text":"

    The goal of this Design Document is to specify the correct behavior of jj run. The points we decide on here I (Philip Metzger) will try to implement. There exists some prior work in other DVCS:

    • git test: part of git-branchless. Similar to this proposal for jj run.
    • hg run: Google's internal Mercurial extension. Similar to this proposal for jj run. Details not available.
    • hg fix: Google's open source Mercurial extension: source code. A more specialized approach to rewriting file content without full context of the working directory.
    • git rebase -x: runs commands opportunistically as part of rebase.
    • git bisect run: run a command to determine which commit introduced a bug.
    "},{"location":"design/run/#context-and-scope","title":"Context and Scope","text":"

    The initial need for some kind of command runner integrated in the VCS, surfaced in a github discussion. In a discussion on discord about the git-hook model, there was consensus about not repeating their mistakes.

    For jj run there is prior art in Mercurial, git branchless and Google's internal Mercurial. Currently git-branchless git test and hg fix implement some kind of command runner. The Google internal hg run works in conjunction with CitC (Clients in the Cloud) which allows it to lazily apply the current command to any affected file. Currently no Jujutsu backend (Git, Native) has a fancy virtual filesystem supporting it, so we can't apply this optimization. We could do the same once we have an implementation of the working copy based on a virtual file system. Until then, we have to run the commands in regular local-disk working copies.

    "},{"location":"design/run/#goals-and-non-goals","title":"Goals and Non-Goals","text":""},{"location":"design/run/#goals","title":"Goals","text":"
    • We should be able to apply the command to any revision, published or unpublished.
    • We should be able to parallelize running the actual command, while preserving a good console output.
    • The run command should be able to work in any commit, the working-copy commit itself or any other commit.
    • There should exist some way to signal hard failure.
    • The command should build enough infrastructure for jj test, jj fix and jj format.
    • The main goal is to be good enough, as we can always expand the functionality in the future.
    "},{"location":"design/run/#non-goals","title":"Non-Goals","text":"
    • While we should build a base for jj test, jj format and jj fix, we shouldn't mash their use-cases into jj run.
    • The command shouldn't be too smart, as too many assumptions about workflows makes the command confusing for users.
    • The smart caching of outputs, as user input commands can be unpredictable. makes the command confusing for users.
    • Avoid the smart caching of outputs, as user input commands can be unpredictable.
    • Fine grained user facing configuration, as it's unwarranted complexity.
    • A fix subcommand as it cuts too much design space.
    "},{"location":"design/run/#use-cases-of-jj-run","title":"Use-Cases of jj run","text":"

    Linting and Formatting:

    • jj run 'pre-commit run' -r $revset
    • jj run 'cargo clippy' -r $revset
    • jj run 'cargo +nightly fmt'

    Large scale changes across repositories, local and remote:

    • jj run 'sed /some/test/' -r 'mine() & ~remote_branches(exact:\"origin\")'
    • jj run '$rewrite-tool' -r '$revset'

    Build systems:

    • jj run 'bazel build //some/target:somewhere'
    • jj run 'ninja check-lld'

    Some of these use-cases should get a specialized command, as this allows further optimization. A command could be jj format, which runs a list of formatters over a subset of a file in a revision. Another command could be jj fix, which runs a command like rustfmt --fix or cargo clippy --fix over a subset of a file in a revision.

    "},{"location":"design/run/#design","title":"Design","text":""},{"location":"design/run/#base-design","title":"Base Design","text":"

    All the work will be done in the .jj/ directory. This allows us to hide all complexity from the users, while preserving the user's current workspace.

    We will copy the approach from git-branchless's git test of creating a temporary working copy for each parallel command. The working copies will be reused between jj run invocations. They will also be reused within jj run invocation if there are more commits to run on than there are parallel jobs.

    We will leave ignored files in the temporary directory between runs. That enables incremental builds (e.g by letting cargo reuse its target/ directory). However, it also means that runs potentially become less reproducible. We will provide a flag for removing ignored files from the temporary working copies to address that.

    Another problem with leaving ignored files in the temporary directories is that they take up space. That is especially problematic in the case of cargo (the target/ directory often takes up tens of GBs). The same flag for cleaning up ignored files can be used to address that. We may want to also have a flag for cleaning up temporary working copies after running the command.

    An early version of the command will directly use Treestate to to manage the temporary working copies. That means that running jj inside the temporary working copies will not work . We can later extend that to use a full Workspace. To prevent operations in the working copies from impacting the repo, we can use a separate OpHeadsStore for it.

    "},{"location":"design/run/#modifying-the-working-copy","title":"Modifying the Working Copy","text":"

    Since the subprocesses will run in temporary working copies, they won't interfere with the user's working copy. The user can therefore continue to work in it while jj run is running.

    We want subprocesses to be able to make changes to the repo by updating their assigned working copy. Let's say the user runs jj run on just commits A and B, where B's parent is A. Any changes made on top of A would be squashed into A, forming A'. Similarly B' would be formed by squasing it into B. We can then either do a normal rebase of B' onto A', or we can simply update its parent to A'. The former is useful, e.g when the subprocess only makes a partial update of the tree based on the parent commit. In addition to these two modes, we may want to have an option to ignore any changes made in the subprocess's working copy.

    "},{"location":"design/run/#modifying-the-repo","title":"Modifying the Repo","text":"

    Once we give the subprocess access to a fork of the repo via separate OpHeadsStore, it will be able to create new operations in its fork. If the user runs jj run -r foo and the subprocess checks out another commit, it's not clear what that should do. We should probably just verify that the working-copy commit's parents are unchanged after the subprocess returns. Any operations created by the subprocess will be ignored.

    "},{"location":"design/run/#rewriting-the-revisions","title":"Rewriting the revisions","text":"

    Like all commands, jj run will refuse to rewrite public/immutable commits. For private/unpublished revisions, we either amend or reparent the changes, which are available as command options.

    "},{"location":"design/run/#execution-orderparallelism","title":"Execution order/parallelism","text":"

    It may be useful to execute commands in topological order. For example, commands with costs proportional to incremental changes, like build systems. There may also be other revelant heuristics, but topological order is an easy and effective way to start.

    Parallel execution of commands on different commits may choose to schedule commits to still reduce incremental changes in the working copy used by each execution slot/\"thread\". However, running the command on all commits concurrently should be possible if desired.

    Executing commands in topological order allows for more meaningful use of any potential features that stop execution \"at the first failure\". For example, when running tests on a chain of commits, it might be useful to proceed in topological/chronological order, and stop on the first failure, because it might imply that the remaining executions will be undesirable because they will also fail.

    "},{"location":"design/run/#dealing-with-failure","title":"Dealing with failure","text":"

    It will be useful to have multiple strategies to deal with failures on a single or multiple revisions. The reason for these strategies is to allow customized conflict handling. These strategies then can be exposed in the ui with a matching option.

    Continue: If any subprocess fails, we will continue the work on child revisions. Notify the user on exit about the failed revisions.

    Stop: Signal a fatal failure and cancel any scheduled work that has not yet started running, but let any already started subprocess finish. Notify the user about the failed command and display the generated error from the subprocess.

    Fatal: Signal a fatal failure and immediately stop processing and kill any running processes. Notify the user that we failed to apply the command to the specific revision.

    We will leave any affected commit in its current state, if any subprocess fails. This allows us provide a better user experience, as leaving revisions in an undesirable state, e.g partially formatted, may confuse users.

    "},{"location":"design/run/#resource-constraints","title":"Resource constraints","text":"

    It will be useful to constrain the execution to prevent resource exhaustion. Relevant resources could include:

    • CPU and memory available on the machine running the commands. jj run can provide some simple mitigations like limiting parallelism to \"number of CPUs\" by default, and limiting parallelism by dividing \"available memory\" by some estimate or measurement of per-invocation memory use of the commands.
    • External resources that are not immediately known to jj. For example, commands run in parallel may wish to limit the total number of connections to a server. We might choose to defer any handling of this to the implementation of the command being invoked, instead of trying to communicate that information to jj.
    "},{"location":"design/run/#command-options","title":"Command Options","text":"

    The base command of any jj command should be usable. By default jj run works on the @ the current working copy.

    • --command, explicit name of the first argument
    • -x, for git compatibility (may alias another command)
    • -j, --jobs, the amount of parallelism to use
    • -k, --keep-going, continue on failure (may alias another command)
    • --show, display the diff for an affected revision
    • --dry-run, do the command execution without doing any work, logging all intended files and arguments
    • --rebase, rebase all parents on the consulitng diff (may alias another command)
    • --reparent, change the parent of an effected revision to the new change (may alias another command)
    • --clean, remove existing workspaces and remove the ignored files
    • --readonly, ignore changes across multiple run invocations
    • --error-strategy=continue|stop|fatal, see Dealing with failure
    "},{"location":"design/run/#integrating-with-other-commands","title":"Integrating with other commands","text":"

    jj log: No special handling needed jj diff: No special handling needed jj st: For now reprint the final output of jj run jj op log: No special handling needed, but awaits further discussion in #963 jj undo/jj op undo: No special handling needed

    "},{"location":"design/run/#open-points","title":"Open Points","text":"

    Should the command be working copy backend specific? How do we manage the Processes which the command will spawn? Configuration options, User and Repository Wide?

    "},{"location":"design/run/#future-possibilities","title":"Future possibilities","text":"
    • We could rewrite the file in memory, which is a neat optimization
    • Exposing some internal state, to allow preciser resource constraints
    • Integration options for virtual filesystems, which allow them to cache the needed working copies.
    • A Jujutsu wide concept for a cached working copy, as they could be expensive to materialize.
    • Customized failure messages, this maybe useful for bots, it could be similar to Bazel's select(..., message = \"arch not supported for $project\").
    • Make jj run asynchronous by spawning a main process, directly return to the user and incrementally updating the output of jj st.
    "},{"location":"design/sparse-v2/","title":"Sparse Patterns v2 redesign","text":"

    Authors: Daniel Ploch

    Summary: This Document documents a redesign of the sparse command and it's internal storage format in jj, in order to facilitate several desirable improvements for large repos. It covers both the migration path and the planned end state.

    "},{"location":"design/sparse-v2/#objective","title":"Objective","text":"

    Redesign Sparse Patterns to accommodate more advanced features for native and custom implementations. This includes three main goals:

    1. Sparse Patterns should be versioned with the working copy
    2. Sparse Patterns should support more flexible matching rules
    3. Sparse Patterns should support client path remapping
    "},{"location":"design/sparse-v2/#current-state-as-of-jj-0130","title":"Current State (as of jj 0.13.0)","text":"

    Sparse patterns are an effectively unordered list of prefix strings:

    path/one\npath/to/dir/two\n

    The set of files identified by the Sparse Patterns is all paths which match any provided prefix. This governs what gets materialized in the working copy on checkout, and what is updated on snapshot. The set is stored in working copy state files which are not versioned in the Op Store.

    Because all paths are bare strings with no escaping or higher-level formatting, the current design makes it difficult to add new features like exclusions or path remappings.

    "},{"location":"design/sparse-v2/#proposed-state-sparse-patterns-v2","title":"Proposed State (Sparse Patterns v2)","text":"

    Sparse Patterns v2 will be stored as objects in the Op Store, referenced by a WorkingCopyPatternsId from the active View. They will have a new, ordered structure which can fully represent previous patterns.

    /// Analogues of RepoPath, specifically describing paths in the working copy.\nstruct WorkingCopyPathBuf {\n    String\n}\nstruct WorkingCopyPath {\n    str\n}\n\npub enum SparsePatternsPathType {\n    Dir,    // Everything under <path>/...\n    Files,  // Files under <path>/*\n    Exact,  // <path> exactly\n}\n\npub struct SparsePatternsPath {\n    path_type: SparsePatternsPathType,\n    include: bool,  // True if included, false if excluded.\n    path: RepoPathBuf,\n}\n\npub struct WorkingCopyMapping {\n    src_path: RepoPathBuf,\n    dst_path: WorkingCopyPathBuf,\n    recursive: bool,  // If false, only immediate children of src_path (files) are renamed.\n}\n\npub struct WorkingCopyPatterns {\n    sparse_paths: Vec<SparsePatternsPath>,\n    mappings: Vec<WorkingCopyMapping>,\n}\n\npub trait OpStore {\n    ...\n    pub fn read_working_copy_patterns(&self, id: &WorkingCopyPatternsId) -> OpStoreResult<WorkingCopyPatterns> { ... }\n    pub fn write_working_copy_patterns(&self, sparse_patterns: &WorkingCopyPatterns) -> OpStoreResult<WorkingCopyPatternsId> { .. }\n}\n

    To support these more complex behaviors, a new WorkingCopyPatterns trait will be introduced, initially only as a thin wrapper around the existing prefix format, but soon to be expanded with richer types and functionality.

    impl WorkingCopyPatterns {\n    pub fn to_matcher(&self) -> Box<dyn Matcher> {\n        ...\n    }\n\n    ...\n}\n
    "},{"location":"design/sparse-v2/#command-syntax","title":"Command Syntax","text":"

    SparsePatternsPath rules can be specified on the CLI and in an editor via a compact syntax:

    (include|exclude):(dir|files|exact):<path>\n

    If both prefix terms are omitted, then include:dir: is assumed. If any prefix is specified, both must be specified. The editor and CLI will both accept path rules in either format going forward.

    • jj sparse set --add foo/bar is equal to jj sparse set --add include:dir:foo/bar
    • jj sparse set --add exclude:dir:foo/bar adds a new Dir type rule with include = false
    • jj sparse set --exclude foo/bar as a possible shorthand for the above
    • jj sparse list will print the explicit rules

    Paths will be stored in an ordered, canonical form which unambiguously describes the set of files to be included. Every --add command will append to the end of this list before the patterns are canonicalized. Whether a file is included is determined by the first matching rule in reverse order.

    For example:

    include:dir:foo\nexclude:dir:foo/bar\ninclude:dir:foo/bar/baz\nexclude:dir:foo/bar/baz/qux\n

    Produces rule set which includes \"foo/file.txt\", excludes \"foo/bar/file.txt\", includes \"foo/bar/baz/file.txt\", and excludes \"foo/bar/baz/qux/file.txt\".

    If the rules are subtly re-ordered, they become canonicalized to a smaller, but functionally equivalent form:

    # Before\ninclude:dir:foo\nexclude:dir:foo/bar/baz/qux\ninclude:dir:foo/bar/baz\nexclude:dir:foo/bar\n\n# Canonicalized\ninclude:dir:foo\nexclude:dir:foo/bar\n
    "},{"location":"design/sparse-v2/#canonicalization","title":"Canonicalization","text":"

    There are many ways to represent functionally equivalent WorkingCopyPatterns. For instance, the following 4 rule sets are all functionally equivalent:

    # Set 1\ninclude:dir:bar\ninclude:dir:foo\n\n# Set 2\ninclude:dir:foo\ninclude:dir:bar\n\n# Set 3\ninclude:dir:bar\ninclude:dir:bar/baz/qux\ninclude:dir:foo\n\n# Set 4\ninclude:dir:foo\nexclude:dir:foo/baz\ninclude:dir:bar\ninclude:dir:foo/baz\n

    Because these patterns are stored in the Op Store now, it is useful for all of these representations to be rewritten into a minimal, canonical form before serialization. In this case, Set 1 will be the canonical set. The canonical form of a WorkingCopyPatterns is defined as the form such that:

    • Every rule affects the functionality (there are no redundant rules)
    • Rules are sorted lexicographically, but with '/' sorted before all else
      • This special sorting order is useful for constructing path tries
    "},{"location":"design/sparse-v2/#working-copy-map","title":"Working Copy Map","text":"

    WARNING: This section is intentionally lacking, more research is needed.

    All WorkingCopyPatterns will come equipped with a default no-op mapping. These mappings are inspired by and similar to Perforce client views.

    vec![WorkingCopyMapping {\n    src_path: RepoPathBuf::root(),\n    dst_path: WorkingCopyPathBuf::root(),\n    recursive: true,\n}]\n

    WorkingCopyPatterns will provide an interface to map working copy paths into repo paths and vice versa. The `WorkingCopy`` trait will apply this mapping to all snapshot and checkout operations, and jj commands which accept relative paths will need to be updated to perform working copy path -> repo path translations as needed. It's not clear at this time which commands will need changing, as some are more likely to refer to repo paths rather than working copy paths.

    TODO: Expand this section.

    In particular, the path rules for sparse patterns will always be repo paths, not working copy paths. Thus, if the working copy wants to track \"foo\" and rename it to \"subdir/bar\", they must jj sparse set --add foo and jj map set --from foo --to bar. In other words, the mapping operation can be thought of as always after the sparse operation.

    "},{"location":"design/sparse-v2/#command-syntax_1","title":"Command Syntax","text":"

    New commands will enable editing of the WorkingCopyMappings:

    TODO: Maybe this should be jj workspace map ...?

    • jj map list will print all mapping pairs.
    • jj map add --from foo --to bar will add a new mapping to the end of the list.
    • jj map remove --from foo will remove a specific mapping rule.
    • jj map edit will pull up a text editor for manual editing.

    Like sparse paths, mappings will have a compact text syntax for editing in file form, or for adding a rule textually on the CLI:

    \"<from>\" -> \"<to>\" [nonrecursive]\n

    Like sparse paths, mapping rules are defined to apply in order and on any save operation will be modified to a minimal canonical form. Thus, jj map set --from \"\" --to \"\" will always completely wipe the map. The first matching rule in reverse list order determines how a particular repo path should be mapped into the working copy, and likewise how a particular working copy path should be mapped into the repo. For simplicity, the 'last rule wins' applies both for repo->WC conversions, as well as WC->repo conversions, using the same ordering.

    If a working copy mapping places the same repo file at two distinct working copy paths, snapshotting will fail unless these files are identical. Some specialized filesystems may even treat these as the 'same' file, allowing this to work in some cases.

    If a working copy mapping places two distinct repo files at the same working copy path, checkout will fail with an error regardless of equivalence.

    "},{"location":"design/sparse-v2/#versioning-and-storage","title":"Versioning and Storage","text":"

    Updating the active WorkingCopyPatterns for a particular working copy will now take place in two separate steps: one transaction which updates the op store, and a separate LockedWorkingCopy operation which actually updates the working copy. The working copy proto will no longer store WorkingCopyPatterns directly, instead storing only a WorkingCopyPatternsId. On mismatch with the current op head, the user will be prompted to run jj workspace update-stale.

    This gives the user the ability to update the active WorkingCopyPatterns whilst not interacting with the local working copy, which is useful for custom integrations which may not be able to check out particular working copy patterns due to problems with the backend (encoding, permission errors, etc.). A bad jj sparse set --add oops command can thus be undone, even via jj op undo if desired.

    "},{"location":"design/sparse-v2/#view-updates","title":"View Updates","text":"

    The View object will be migrated to store working copy patterns via id. The indirection will save on storage since working copy patterns are not expected to change very frequently.

    // Before:\npub wc_commit_ids: HashMap<WorkspaceId, CommitId>,\n\n// After:\npub struct WorkingCopyInfo {\n    pub commit_id: CommitId,\n    pub wc_patterns_id: WorkingCopyPatternsId,\n}\n...\npub wc_info: HashMap<WorkspaceId, WorkingCopyInfo>,\n

    A View object with no stored working copy patterns will be modified at read time to include the current working copy patterns, thus all read_view operations will need to pass in the current working copy patterns for a migration period of at least 6 months. After that, we may choose to auto-fill missing working copy infos with a default WorkingCopyPatterns as needed.

    "},{"location":"design/sparse-v2/#appendix","title":"Appendix","text":""},{"location":"design/sparse-v2/#related-work","title":"Related Work","text":"

    Perforce client maps are very similar in concept to the entirety of WorkingCopyPatterns, and this design aims to achieve similar functionality.

    The Josh Project implements partial git clones in a way similar to how sparse patterns try to work.

    "},{"location":"design/sparse-v2/#patterns-via-configuration","title":"Patterns via configuration","text":"

    There may be some scenarios where it is valuable to configure working copy patterns via a configuration file, rather than through explicit commands. Generally this only makes sense for automated repos, with the configuration coming from outside the repo - there are too many caveats and edge cases if the configuration comes from inside the repo and/or is fought with by a human.

    No configuration syntax is planned at this time but if we add any, we should probably reuse the compact line syntaxes as much as possible for consistency.

    "},{"location":"design/tracking-branches/","title":"Remote/@git tracking branches","text":"

    This is a plan to implement more Git-like remote tracking branch UX.

    "},{"location":"design/tracking-branches/#objective","title":"Objective","text":"

    jj imports all remote branches to local branches by default. As described in #1136, this doesn't interact nicely with Git if we have multiple Git remotes with a number of branches. The git.auto-local-branch config can mitigate this problem, but we'll get locally-deleted branches instead.

    The goal of this plan is to implement

    • proper support for tracking/non-tracking remote branches
    • logically consistent data model for importing/exporting Git refs
    "},{"location":"design/tracking-branches/#current-data-model-as-of-jj-080","title":"Current data model (as of jj 0.8.0)","text":"

    Under the current model, all remote branches are \"tracking\" branches, and remote changes are merged into the local counterparts.

    branches\n  [name]:\n    local_target?\n    remote_targets[remote]: target\ntags\n  [name]: target\ngit_refs\n  [\"refs/heads/{name}\"]: target             # last-known local branches\n  [\"refs/remotes/{remote}/{name}\"]: target  # last-known remote branches\n                                            # (copied to remote_targets)\n  [\"refs/tags/{name}\"]: target              # last-known tags\ngit_head: target?\n
    • Remote branches are stored in both branches[name].remote_targets and git_refs[\"refs/remotes\"]. These two are mostly kept in sync, but there are two scenarios where remote-tracking branches and git refs can diverge:
      1. jj branch forget
      2. jj op undo/restore in colocated repo
    • Pseudo @git tracking branches are stored in git_refs[\"refs/heads\"]. We need special case to resolve @git branches, and their behavior is slightly different from the other remote-tracking branches.
    "},{"location":"design/tracking-branches/#proposed-data-model","title":"Proposed data model","text":"

    We'll add a per-remote-branch state to distinguish non-tracking branches from tracking ones.

    state = new        # not merged in the local branch or tag\n      | tracking   # merged in the local branch or tag\n# `ignored` state could be added if we want to manage it by view, not by\n# config file. target of ignored remote branch would be absent.\n

    We'll add a per-remote view-like object to record the last known remote branches. It will replace branches[name].remote_targets in the current model. @git branches will be stored in remotes[\"git\"].

    branches\n  [name]: target\ntags\n  [name]: target\nremotes\n  [\"git\"]:\n    branches\n      [name]: target, state                 # refs/heads/{name}\n    tags\n      [name]: target, state = tracking      # refs/tags/{name}\n    head: target?, state = TBD              # refs/HEAD\n  [remote]:\n    branches\n      [name]: target, state                 # refs/remotes/{remote}/{name}\n    tags: (empty)\n    head: (empty)\ngit_refs                                    # last imported/exported refs\n  [\"refs/heads/{name}\"]: target\n  [\"refs/remotes/{remote}/{name}\"]: target\n  [\"refs/tags/{name}\"]: target\n

    With the proposed data model, we can

    • naturally support remote branches which have no local counterparts
    • deduplicate branches[name].remote_targets and git_refs[\"refs/remotes\"]
    "},{"location":"design/tracking-branches/#importexport-data-flow","title":"Import/export data flow","text":"
           export flow                              import flow\n       -----------                              -----------\n                        +----------------+                   --.\n   +------------------->|backing Git repo|---+                 :\n   |                    +----------------+   |                 : unchanged\n   |[update]                                 |[copy]           : on \"op restore\"\n   |                      +----------+       |                 :\n   |      +-------------->| git_refs |<------+                 :\n   |      |               +----------+       |               --'\n   +--[compare]                            [diff]--+\n          |   .--       +---------------+    |     |         --.\n          |   :    +--->|remotes[\"git\"] |    |     |           :\n          +---:    |    |               |<---+     |           :\n              :    |    |remotes[remote]|          |           : restored\n              '--  |    +---------------+          |[merge]    : on \"op restore\"\n                   |                               |           : by default\n             [copy]|    +---------------+          |           :\n                   +----| (local)       |<---------+           :\n                        | branches/tags |                      :\n                        +---------------+                    --'\n
    • jj git import applies diff between git_refs and remotes[]. git_refs is always copied from the backing Git repo.
    • jj git export copies jj's remotes view back to the Git repo. If a ref in the Git repo has been updated since the last import, the ref isn't exported.
    • jj op restore never rolls back git_refs.
    "},{"location":"design/tracking-branches/#tracking-state","title":"Tracking state","text":"

    The git.auto-local-branch config knob is applied when importing new remote branch. jj branch sub commands will be added to change the tracking state.

    fn default_state_for_newly_imported_branch(config, remote) {\n    if remote == \"git\" {\n        State::Tracking\n    } else if config[\"git.auto-local-branch\"] {\n        State::Tracking\n    } else {\n        State::New\n    }\n}\n

    A branch target to be merged is calculated based on the state.

    fn target_in_merge_context(known_target, state) {\n    match state {\n        State::New => RefTarget::absent(),\n        State::Tracking => known_target,\n    }\n}\n
    "},{"location":"design/tracking-branches/#mapping-to-the-current-data-model","title":"Mapping to the current data model","text":"
    • New remotes[\"git\"].branches corresponds to git_refs[\"refs/heads\"], but forgotten branches are removed from remotes[\"git\"].branches.
    • New remotes[\"git\"].tags corresponds to git_refs[\"refs/tags\"].
    • New remotes[\"git\"].head corresponds to git_head.
    • New remotes[remote].branches corresponds to branches[].remote_targets[remote].
    • state = new|tracking doesn't exist in the current model. It's determined by git.auto-local-branch config.
    "},{"location":"design/tracking-branches/#common-command-behaviors","title":"Common command behaviors","text":"

    In the following sections, a merge is expressed as adds - removes. In particular, a merge of local and remote targets is [local, remote] - [known_remote].

    "},{"location":"design/tracking-branches/#fetchimport","title":"fetch/import","text":"
    • jj git fetch

      1. Fetches remote changes to the backing Git repo.
      2. Import changes only for remotes[remote].branches[glob] (see below)
        • TODO: how about fetched .tags?
    • jj git import

      1. Copies git_refs from the backing Git repo.
      2. Calculates diff from the known remotes to the new git_refs.
        • git_refs[\"refs/heads\"] - remotes[\"git\"].branches
        • git_refs[\"refs/tags\"] - remotes[\"git\"].tags
        • TBD: \"HEAD\" - remotes[\"git\"].head (unused)
        • git_refs[\"refs/remotes/{remote}\"] - remotes[remote]
      3. Merges diff in local branches and tags if state is tracking.
        • If the known target is absent, the default state should be calculated. This also applies to previously-forgotten branches.
      4. Updates remotes reflecting the import.
      5. Abandons commits that are no longer referenced.
    "},{"location":"design/tracking-branches/#pushexport","title":"push/export","text":"
    • jj git push

      1. Calculates diff from the known remotes[remote] to the local changes.
        • branches - remotes[remote].branches
          • If state is new (i.e. untracked), the known remote branch target is considered absent.
          • If state is new, and if the local branch target is absent, the diff [absent, remote] - absent is noop. So it's not allowed to push deleted branch to untracked remote.
          • TODO: Copy Git's --force-with-lease behavior?
        • ~tags~ (not implemented, but should be the same as branches)
      2. Pushes diff to the remote Git repo (as well as remote tracking branches in the backing Git repo.)
      3. Updates remotes[remote] and git_refs reflecting the push.
    • jj git export

      1. Copies local branches/tags back to remotes[\"git\"].
        • Conceptually, remotes[\"git\"].branches[name].state can be set to untracked. Untracked local branches won't be exported to Git.
        • If remotes[\"git\"].branches[name] is absent, the default state = tracking applies. This also applies to forgotten branches.
        • ~tags~ (not implemented, but should be the same as branches)
      2. Calculates diff from the known git_refs to the new remotes[remote].
      3. Applies diff to the backing Git repo.
      4. Updates git_refs reflecting the export.

      If a ref failed to export at the step 3, the preceding steps should also be rolled back for that ref.

    "},{"location":"design/tracking-branches/#initclone","title":"init/clone","text":"
    • jj init

      • Import, track, and merge per git.auto_local_branch config.
      • If !git.auto_local_branch, no tracking state will be set.
    • jj git clone

      • Import, track, and merge per git.auto_local_branch config.
      • The default branch will be tracked regardless of git.auto_local_branch config. This isn't technically needed, but will help users coming from Git.
    "},{"location":"design/tracking-branches/#branch","title":"branch","text":"
    • jj branch set {name}
      1. Sets local branches[name] entry.
    • jj branch delete {name}
      1. Removes local branches[name] entry.
    • jj branch forget {name}
      1. Removes local branches[name] entry if exists.
      2. Removes remotes[remote].branches[name] entries if exist. TODO: maybe better to not remove non-tracking remote branches?
    • jj branch track {name}@{remote} (new command)
      1. Merges [local, remote] - [absent] in local branch.
        • Same as \"fetching/importing existing branch from untracked remote\".
      2. Sets remotes[remote].branches[name].state = tracking.
    • jj branch untrack {name}@{remote} (new command)
      1. Sets remotes[remote].branches[name].state = new.
    • jj branch list
      • TODO: hide non-tracking branches by default? ...

    Note: desired behavior of jj branch forget is to

    • discard both local and remote branches (without actually removing branches at remotes)
    • not abandon commits which belongs to those branches (even if the branch is removed at a remote)
    "},{"location":"design/tracking-branches/#command-behavior-examples","title":"Command behavior examples","text":""},{"location":"design/tracking-branches/#fetchimport_1","title":"fetch/import","text":"
    • Fetching/importing new branch
      1. Decides new state = new|tracking based on git.auto_local_branch
      2. If new state is tracking, merges [absent, new_remote] - [absent] (i.e. creates local branch with new_remote target)
      3. Sets remotes[remote].branches[name].state
    • Fetching/importing existing branch from tracking remote
      1. Merges [local, new_remote] - [known_remote]
    • Fetching/importing existing branch from untracked remote
      1. Decides new state = new|tracking based on git.auto_local_branch
      2. If new state is tracking, merges [local, new_remote] - [absent]
      3. Sets remotes[remote].branches[name].state
    • Fetching/importing remotely-deleted branch from tracking remote
      1. Merges [local, absent] - [known_remote]
      2. Removes remotes[remote].branches[name] (target becomes absent) (i.e. the remote branch is no longer tracked)
      3. Abandons commits in the deleted branch
    • Fetching/importing remotely-deleted branch from untracked remote
      1. Decides new state = new|tracking based on git.auto_local_branch
      2. Noop anyway since [local, absent] - [absent] -> local
    • Fetching previously-forgotten branch from remote
      1. Decides new state = new|tracking based on git.auto_local_branch
      2. If new state is tracking, merges [absent, new_remote] - [absent] -> new_remote
      3. Sets remotes[remote].branches[name].state
    • Fetching forgotten and remotely-deleted branch
      • Same as \"remotely-deleted branch from untracked remote\" since forgotten remote branch should be state = new
      • Therefore, no local commits should be abandoned
    "},{"location":"design/tracking-branches/#push","title":"push","text":"
    • Pushing new branch, remote doesn't exist
      1. Pushes [local, absent] - [absent] -> local
      2. Sets remotes[remote].branches[name].target = local, .state = tracking
    • Pushing new branch, untracked remote exists
      1. Pushes [local, remote] - [absent]
        • Fails if local moved backwards or sideways
      2. Sets remotes[remote].branches[name].target = local, .state = tracking
    • Pushing existing branch to tracking remote
      1. Pushes [local, remote] - [remote] -> local
        • Fails if local moved backwards or sideways, and if remote is out of sync
      2. Sets remotes[remote].branches[name].target = local
    • Pushing existing branch to untracked remote
      • Same as \"new branch\"
    • Pushing deleted branch to tracking remote
      1. Pushes [absent, remote] - [remote] -> absent
        • TODO: Fails if remote is out of sync?
      2. Removes remotes[remote].branches[name] (target becomes absent)
    • Pushing deleted branch to untracked remote
      • Noop since [absent, remote] - [absent] -> remote
      • Perhaps, UI will report error
    • Pushing forgotten branch to untracked remote
      • Same as \"deleted branch to untracked remote\"
    • Pushing previously-forgotten branch to remote
      • Same as \"new branch, untracked remote exists\"
      • The target of forgotten remote branch is absent
    "},{"location":"design/tracking-branches/#export","title":"export","text":"
    • Exporting new local branch, git branch doesn't exist
      1. Sets remotes[\"git\"].branches[name].target = local, .state = tracking
      2. Exports [local, absent] - [absent] -> local
    • Exporting new local branch, git branch is out of sync
      1. Exports [local, git] - [absent] -> fail
    • Exporting existing local branch, git branch is synced
      1. Sets remotes[\"git\"].branches[name].target = local
      2. Exports [local, git] - [git] -> local
    • Exporting deleted local branch, git branch is synced
      1. Removes remotes[\"git\"].branches[name]
      2. Exports [absent, git] - [git] -> absent
    • Exporting forgotten branches, git branches are synced
      1. Exports [absent, git] - [git] -> absent for forgotten local/remote branches
    "},{"location":"design/tracking-branches/#undo-fetch","title":"undo fetch","text":"
    • Exporting undone fetch, git branches are synced
      1. Exports [old, git] - [git] -> old for undone local/remote branches
    • Redoing undone fetch without exporting
      • Same as plain fetch since the known git_refs isn't diffed against the refs in the backing Git repo.
    "},{"location":"design/tracking-branches/#git-remote","title":"@git remote","text":"
    • jj branch untrack {name}@git
      • Maybe rejected (to avoid confusion)?
      • Allowing this would mean different local branches of the same name coexist in jj and git.
    • jj git fetch --remote git
      • Rejected. The implementation is different.
      • Conceptually, it's git::import_refs() only for local branches.
    • jj git push --remote git
      • Rejected. The implementation is different.
      • Conceptually, it's jj branch track and git::export_refs() only for local branches.
    "},{"location":"design/tracking-branches/#remaining-issues","title":"Remaining issues","text":"
    • https://github.com/martinvonz/jj/issues/1278 pushing to tracked remote
      • Option could be added to push to all tracking remotes?
    • Track remote branch locally with different name
      • Local branch name could be stored per remote branch
      • Consider UI complexity
    • \"private\" state (suggested by @ilyagr)
      • \"private\" branches can be pushed to their own remote, but not to the upstream repo
      • This might be a state attached to a local branch (similar to Mercurial's \"secret\" phase)
    "},{"location":"design/tracking-branches/#references","title":"References","text":"
    • https://github.com/martinvonz/jj/issues/1136
    • https://github.com/martinvonz/jj/issues/1666
    • https://github.com/martinvonz/jj/issues/1690
    • https://github.com/martinvonz/jj/issues/1734
    • https://github.com/martinvonz/jj/pull/1739
    "},{"location":"technical/architecture/","title":"Architecture","text":""},{"location":"technical/architecture/#data-model","title":"Data model","text":"

    The commit data model is similar to Git's object model , but with some differences.

    "},{"location":"technical/architecture/#separation-of-library-from-ui","title":"Separation of library from UI","text":"

    The jj binary consists of two Rust crates: the library crate (jj-lib) and the CLI crate (jj-cli). The library crate is currently only used by the CLI crate, but it is meant to also be usable from a GUI or TUI, or in a server serving requests from multiple users. As a result, the library should avoid interacting directly with the user via the terminal or by other means; all input/output is handled by the CLI crate 1. Since the library crate is meant to usable in a server, it also cannot read configuration from the user's home directory, or from user-specific environment variables.

    A lot of thought has gone into making the library crate's API easy to use, but not much has gone into \"details\" such as which collection types are used, or which symbols are exposed in the API.

    "},{"location":"technical/architecture/#storage-independent-apis","title":"Storage-independent APIs","text":"

    One overarching principle in the design is that it should be easy to change where data is stored. The goal was to be able to put storage on local-disk by default but also be able to move storage to the cloud at Google (and for anyone). To that end, commits (and trees, files, etc.) are stored by the commit backend, operations (and views) are stored by the operation backend, the heads of the operation log are stored by the \"op heads\" backend, the commit index is stored by the index backend, and the working copy is stored by the working copy backend. The interfaces are defined in terms of plain Rust data types, not tied to a specific format. The working copy doesn't have its own trait defined yet, but its interface is small and easy to create traits for when needed.

    The commit backend to use when loading a repo is specified in the .jj/repo/store/type file. There are similar files for the other backends (.jj/repo/index/type, .jj/repo/op_store/type, .jj/repo/op_heads/type).

    "},{"location":"technical/architecture/#design-of-the-library-crate","title":"Design of the library crate","text":""},{"location":"technical/architecture/#overview","title":"Overview","text":"

    Here's a diagram showing some important types in the library crate. The following sections describe each component.

    graph TD;\n    ReadonlyRepo-->Store;\n    ReadonlyRepo-->OpStore;\n    ReadonlyRepo-->OpHeadsStore;\n    ReadonlyRepo-->ReadonlyIndex\n    MutableIndex-->ReadonlyIndex;\n    Store-->Backend;\n    GitBackend-->Backend;\n    LocalBackend-->Backend;\n    LocalBackend-->StackedTable;\n    MutableRepo-->ReadonlyRepo;\n    MutableRepo-->MutableIndex;\n    Transaction-->MutableRepo;\n    WorkingCopy-->TreeState;\n    Workspace-->WorkingCopy;\n    Workspace-->RepoLoader;\n    RepoLoader-->Store;\n    RepoLoader-->OpStore;\n    RepoLoader-->OpHeadsStore;\n    RepoLoader-->ReadonlyRepo;\n    Git-->GitBackend;\n    GitBackend-->StackedTable;
    "},{"location":"technical/architecture/#backend","title":"Backend","text":"

    The Backend trait defines the interface each commit backend needs to implement. The current in-tree commit backends are GitBackend and LocalBackend.

    Since there are non-commit backends, the Backend trait should probably be renamed to CommitBackend.

    "},{"location":"technical/architecture/#gitbackend","title":"GitBackend","text":"

    The GitBackend stores commits in a Git repository. It uses libgit2 to read and write commits and refs.

    To prevent GC from deleting commits that are still reachable from the operation log, the GitBackend stores a ref for each commit in the operation log in the refs/jj/keep/ namespace.

    Commit data that is available in Jujutsu's model but not in Git's model is stored in a StackedTable in .jj/repo/store/extra/. That is currently the change ID and the list of predecessors. For commits that don't have any data in that table, which is any commit created by git, we use an empty list as predecessors, and the bit-reversed commit ID as change ID.

    Because we use the Git Object ID as commit ID, two commits that differ only in their change ID, for example, will get the same commit ID, so we error out when trying to write the second one of them.

    "},{"location":"technical/architecture/#localbackend","title":"LocalBackend","text":"

    The LocalBackend is just a proof of concept. It stores objects addressed by their hash, with one file per object.

    "},{"location":"technical/architecture/#store","title":"Store","text":"

    The Store type wraps the Backend and returns wrapped types for commits and trees to make them easier to use. The wrapped objects have a reference to the Store itself, so you can do e.g. commit.parents() without having to provide the Store as an argument.

    The Store type also provides caching of commits and trees.

    "},{"location":"technical/architecture/#readonlyrepo","title":"ReadonlyRepo","text":"

    A ReadonlyRepo represents the state of a repo at a specific operation. It keeps the view object associated with that operation.

    The repository doesn't know where on disk any working copies live. It knows, via the view object, which commit is supposed to be the current working-copy commit in each workspace.

    "},{"location":"technical/architecture/#mutablerepo","title":"MutableRepo","text":"

    A MutableRepo is a mutable version of ReadonlyRepo. It has a reference to its base ReadonlyRepo, but it has its own copy of the view object and lets the caller modify it.

    "},{"location":"technical/architecture/#transaction","title":"Transaction","text":"

    The Transaction object has a MutableRepo and metadata that will go into the operation log. When the transaction commits, the MutableRepo becomes a view object in the operation log on disk, and the Transaction object becomes an operation object. In memory, Transaction::commit() returns a new ReadonlyRepo.

    "},{"location":"technical/architecture/#repoloader","title":"RepoLoader","text":"

    The RepoLoader represents a repository at an unspecified operation. You can think of as a pointer to the .jj/repo/ directory. It can create a ReadonlyRepo given an operation ID.

    "},{"location":"technical/architecture/#treestate","title":"TreeState","text":"

    The TreeState type represents the state of the files in a working copy. It keep track of the mtime and size for each tracked file. It knows the TreeId that the working copy represents. It has a snapshot() method that will use the recorded mtimes and sizes and detect changes in the working copy. If anything changed, it will return a new TreeId. It also has checkout() for updating the files on disk to match a requested TreeId.

    The TreeState type supports sparse checkouts. In fact, all working copies are sparse; they simply track the full repo in most cases.

    "},{"location":"technical/architecture/#workingcopy","title":"WorkingCopy","text":"

    The WorkingCopy type has a TreeState but also knows which WorkspaceId it has and at which operation it was most recently updated.

    "},{"location":"technical/architecture/#workspace","title":"Workspace","text":"

    The Workspace type represents the combination of a repo and a working copy ( like Git's 'worktree' concept).

    The repo view at the current operation determines the desired working-copy commit in each workspace. The WorkingCopy determines what is actually in the working copy. The working copy can become stale if the working-copy commit was changed from another workspace (or if the process updating the working copy crashed, for example).

    "},{"location":"technical/architecture/#git","title":"Git","text":"

    The git module contains functionality for interoperating with a Git repo, at a higher level than the GitBackend. The GitBackend is restricted by the Backend trait; the git module is specifically for Git-backed repos. It has functionality for importing refs from the Git repo and for exporting to refs in the Git repo. It also has functionality for pushing and pulling to/from Git remotes.

    "},{"location":"technical/architecture/#revsets","title":"Revsets","text":"

    A user-provided revset expression string goes through a few different stages to be evaluated:

    1. Parse the expression into a RevsetExpression, which is close to an AST
    2. Resolve symbols and functions like tags() into specific commits. After this stage, the expression is still a RevsetExpression, but it won't have any CommitRef variants in it.
    3. Resolve visibility. This stage resolves visible_heads() and all() and produces a ResolvedExpression.
    4. Evaluate the ResolvedExpression into a Revset.

    This evaluation step is performed by Index::evaluate_revset(), allowing the Revset implementation to leverage the specifics of a custom index implementation. The first three steps are independent of the index implementation.

    "},{"location":"technical/architecture/#stackedtable","title":"StackedTable","text":"

    StackedTable (actually ReadonlyTable and MutableTable) is a simple disk format for storing key-value pairs sorted by key. The keys have to have the same size but the values can have different sizes. We use our own format because we want lock-free concurrency and there doesn't seem to be an existing key-value store we could use.

    The file format contains a lookup table followed by concatenated values. The lookup table is a sorted list of keys, where each key is followed by the associated value's offset in the concatenated values.

    A table can have a parent table. When looking up a key, if it's not found in the current table, the parent table is searched. We never update a table in place. If the number of new entries to write is less than half the number of entries in the parent table, we create a new table with the new entries and a pointer to the parent. Otherwise, we copy the entries from the parent table and the new entries into a new table with the grandparent as the parent. We do that recursively so parent tables are at least 2 times as large as child tables. This results in O(log N) amortized insertion time and lookup time.

    There's no garbage collection of unreachable tables yet.

    The tables are named by their hash. We keep a separate directory of pointers to the current leaf tables, in the same way as we do for the operation log.

    "},{"location":"technical/architecture/#design-of-the-cli-crate","title":"Design of the CLI crate","text":""},{"location":"technical/architecture/#templates","title":"Templates","text":"

    The concept is copied from Mercurial, but the syntax is different. The main difference is that the top-level expression is a template expression, not a string like in Mercurial. There is also no string interpolation (e.g. \"Commit ID: {node}\" in Mercurial).

    "},{"location":"technical/architecture/#diff-editing","title":"Diff-editing","text":"

    Diff-editing works by creating two very sparse working copies, containing only the files we want the user to edit. We then let the user edit the right-hand side of the diff. Then we simply snapshot that working copy to create the new tree.

    1. There are a few exceptions, such as for messages printed during automatic upgrades of the repo format\u00a0\u21a9

    "},{"location":"technical/concurrency/","title":"Concurrency","text":""},{"location":"technical/concurrency/#introduction","title":"Introduction","text":"

    Concurrent editing is a key feature of DVCSs -- that's why they're called Distributed Version Control Systems. A DVCS that didn't let users edit files and create commits on separate machines at the same time wouldn't be much of a distributed VCS.

    When conflicting changes are made in different clones, a DVCS will have to deal with that when you push or pull. For example, when using Mercurial, if the remote has updated a bookmark called main (Mercurial's bookmarks are similar to a Git's branches) and you had updated the same bookmark locally but made it point to a different target, Mercurial would add a bookmark called main@origin to indicate the conflict. Git instead prevents the conflict by renaming pulled branches to origin/main whether or not there was a conflict. However, most DVCSs treat local concurrency quite differently, typically by using lock files to prevent concurrent edits. Unlike those DVCSs, Jujutsu treats concurrent edits the same whether they're made locally or remotely.

    One problem with using lock files is that they don't work when the clone is in a distributed file system. Most clones are of course not stored in distributed file systems, but it is a big problem when they are (Mercurial repos frequently get corrupted, for example).

    Another problem with using lock files is related to complexity of implementation. The simplest way of using lock files is to take coarse-grained locks early: every command that may modify the repo takes a lock at the very beginning. However, that means that operations that wouldn't actually conflict would still have to wait for each other. The user experience can be improved by using finer-grained locks and/or taking the locks later. The drawback of that is complexity. For example, you need to verify that any assumptions you made before locking are still valid after you take the lock.

    To avoid depending on lock files, Jujutsu takes a different approach by accepting that concurrent changes can always happen. It instead exposes any conflicting changes to the user, much like other DVCSs do for conflicting changes made remotely.

    "},{"location":"technical/concurrency/#syncing-with-rsync-nfs-dropbox-etc","title":"Syncing with rsync, NFS, Dropbox, etc","text":"

    Jujutsu's lock-free concurrency means that it's possible to update copies of the clone on different machines and then let rsync (or Dropbox, or NFS, etc.) merge them. The working copy may mismatch what's supposed to be checked out, but no changes to the repo will be lost (added commits, moved branches, etc.). If conflicting changes were made, they will appear as conflicts. For example, if a branch was moved to two different locations, they will appear in jj log in both locations but with a \"?\" after the name, and jj status will also inform the user about the conflict.

    Note that, for now, there are known bugs in this area. Most notably, with the Git backend, repository corruption is possible because the backend is not entirely lock-free. If you know about the bug, it is relatively easy to recover from.

    Moreover, such use of Jujutsu is not currently thoroughly tested, especially in the context of co-located repositories. While the contents of commits should be safe, concurrent modification of a repository from different computers might conceivably lose some branch pointers. Note that, unlike in pure Git, losing a branch pointer does not lead to losing commits.

    "},{"location":"technical/concurrency/#operation-log","title":"Operation log","text":"

    The most important piece in the lock-free design is the \"operation log\". That is what allows us to detect and merge concurrent operations.

    The operation log is similar to a commit DAG (such as in Git's object model), but each commit object is instead an \"operation\" and each tree object is instead a \"view\". The view object contains the set of visible head commits, branches, tags, and the working-copy commit in each workspace. The operation object contains a pointer to the view object (like how commit objects point to tree objects), pointers to parent operation(s) (like how commit objects point to parent commit(s)), and metadata about the operation. These types are defined in op_store.proto The operation log is normally linear. It becomes non-linear if there are concurrent operations.

    When a command starts, it loads the repo at the latest operation. Because the associated view object completely defines the repo state, the running command will not see any changes made by other processes thereafter. When the operation completes, it is written with the start operation as parent. The operation cannot fail to commit (except for disk failures and such). It is left for the next command to notice if there were concurrent operations. It will have to be able to do that anyway since the concurrent operation could have arrived via a distributed file system. This model -- where each operation sees a consistent view of the repo and is guaranteed to be able to commit their changes -- greatly simplifies the implementation of commands.

    It is possible to load the repo at a particular operation with jj --at-operation=<operation ID> <command>. If the command is mutational, that will result in a fork in the operation log. That works exactly the same as if any later operations had not existed when the command started. In other words, running commands on a repo loaded at an earlier operation works the same way as if the operations had been concurrent. This can be useful for simulating concurrent operations.

    "},{"location":"technical/concurrency/#merging-concurrent-operations","title":"Merging concurrent operations","text":"

    If Jujutsu tries to load the repo and finds multiple heads in the operation log, it will do a 3-way merge of the view objects based on their common ancestor (possibly several 3-way merges if there were more than two heads). Conflicts are recorded in the resulting view object. For example, if branch main was moved from commit A to commit B in one operation and moved to commit C in a concurrent operation, then main will be recorded as \"moved from A to B or C\". See the RefTarget definition in op_store.proto.

    Because we allow branches (etc.) to be in a conflicted state rather than just erroring out when there are multiple heads, the user can continue to use the repo, including performing further operations on the repo. Of course, some commands will fail when using a conflicted branch. For example, jj checkout main when main is in a conflicted state will result in an error telling you that main resolved to multiple revisions.

    "},{"location":"technical/concurrency/#storage","title":"Storage","text":"

    The operation objects and view objects are stored in content-addressed storage just like Git commits are. That makes them safe to write without locking.

    We also need a way of finding the current head of the operation log. We do that by keeping the ID of the current head(s) as a file in a directory. The ID is the name of the file; it has no contents. When an operation completes, we add a file pointing to the new operation and then remove the file pointing to the old operation. Writing the new file is what makes the operation visible (if the old file didn't get properly deleted, then future readers will take care of that). This scheme ensures that transactions are atomic.

    "},{"location":"technical/conflicts/","title":"First-class conflicts","text":""},{"location":"technical/conflicts/#introduction","title":"Introduction","text":"

    Conflicts can happen when two changes are applied to some state. This document is about conflicts between changes to files (not about conflicts between changes to branch targets, for example).

    For example, if you merge two branches in a repo, there may be conflicting changes between the two branches. Most DVCSs require you to resolve those conflicts before you can finish the merge operation. Jujutsu instead records the conflicts in the commit and lets you resolve the conflict when you feel like it.

    "},{"location":"technical/conflicts/#data-model","title":"Data model","text":"

    When a merge conflict happens, it is recorded as an ordered list of tree objects linked from the commit (instead of the usual single tree per commit). There will always be an odd number of trees linked from the commit. You can think of the first tree as a start tree, and the subsequent pairs of trees to apply the diff between onto the start. Examples:

    • If the commit has trees A, B, C, D, and E it means that the contents should be calculated as A+(C-B)+(E-D).
    • A three-way merge between A and C with B as base can be represented as a commit with trees A, B, and C, also known as A+(C-B).

    The resulting tree contents is calculated on demand. Note that we often don't need to merge the entire tree. For example, when checking out a commit in the working copy, we only need to merge parts of the tree that differs from the tree that was previously checked out in the working copy. As another example, when listing paths with conflicts, we only need to traverse parts of the tree that cannot be trivially resolved; if only one side modified lib/, then we don't need to look for conflicts in that sub-tree.

    When merging trees, if we can't resolve a sub-tree conflict trivially by looking at just the tree id, we recurse into the sub-tree. Similarly, if we can't resolve a file conflict trivially by looking at just the id, we recursive into the hunks within the file.

    See here for how conflicts are stored when using the Git commit backend.

    "},{"location":"technical/conflicts/#conflict-simplification","title":"Conflict simplification","text":"

    Remember that a 3-way merge can be written A+C-B. If one of those states is itself a conflict, then we simply insert the conflict expression there. Then we simplify by removing canceling terms. These two steps are implemented in Merge::flatten() and Merge::simplify() in merge.rs.

    For example, let's say commit B is based on A and is rebased to C, where it results in conflicts (B+C-A), which the user leaves unresolved. If the commit is then rebased to D, the result will be (B+C-A)+(D-C) (D-C comes from changing the base from C to D). That expression can be simplified to B+D-A, which is a regular 3-way merge between B and D with A as base (no trace of C). This is what lets the user keep old commits rebased to head without resolving conflicts and still not get messy recursive conflicts.

    As another example, let's go through what happens when you back out a conflicted commit. Let's say we have the usual B+C-A conflict on top of non-conflict state C. We then back out that change. Backing out (\"reverting\" in Git-speak) a change means applying its reverse diff, so the result is (B+C-A)+(A-(B+C-A)), which we can simplify to just A (i.e. no conflict).

    "}]} \ No newline at end of file +{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Jujutsu\u2014a version control system","text":""},{"location":"#welcome-to-jjs-documentation-website","title":"Welcome to jj's documentation website!","text":"

    The complete list of the available documentation pages is located in the sidebar on the left of the page. The sidebar may be hidden; if so, you can open it either by widening your browser window or by clicking on the hamburger menu that appears in this situation.

    Additional help is available using the jj help command if you have jj installed.

    You may want to jump to:

    • Documentation for the latest released version of jj.
    • Documentation for the unreleased version of jj. This version of the docs corresponds to the main branch of the jj repo.
    "},{"location":"#some-useful-links","title":"Some useful links","text":"
    • GitHub repo for jj
    • Overview of jj in the repo's README
    • Installation and Setup
    • Tutorial and Birds-Eye View
    • Working with GitHub
    "},{"location":"FAQ/","title":"Frequently asked questions","text":""},{"location":"FAQ/#why-does-my-branch-not-move-to-the-new-commit-after-jj-newcommit","title":"Why does my branch not move to the new commit after jj new/commit?","text":"

    If you're familiar with Git, you might expect the current branch to move forward when you commit. However, Jujutsu does not have a concept of a \"current branch\".

    To move branches, use jj branch set.

    "},{"location":"FAQ/#i-made-a-commit-and-jj-git-push-all-says-nothing-changed-instead-of-pushing-it-what-do-i-do","title":"I made a commit and jj git push --all says \"Nothing changed\" instead of pushing it. What do I do?","text":"

    jj git push --all pushes all branches, not all revisions. You have two options:

    • Using jj git push --change will automatically create a branch and push it.
    • Using jj branch commands to create or move a branch to either the commit you want to push or a descendant on it. Unlike Git, Jujutsu doesn't do this automatically (see previous question).
    "},{"location":"FAQ/#where-is-my-commit-why-is-it-not-visible-in-jj-log","title":"Where is my commit, why is it not visible in jj log?","text":"

    Is your commit visible with jj log -r 'all()'?

    If yes, you should be aware that jj log only shows the revisions matching revsets.log by default. You can change it as described in config to show more revisions.

    If not, the revision may have been abandoned (e.g. because you used jj abandon, or because it's an obsolete version that's been rewritten with jj rebase, jj describe, etc). In that case, jj log -r commit_id should show the revision as \"hidden\". jj new commit_id should make the revision visible again.

    See revsets and templates for further guidance.

    "},{"location":"FAQ/#how-can-i-get-jj-log-to-show-me-what-git-log-would-show-me","title":"How can I get jj log to show me what git log would show me?","text":"

    Use jj log -r ... The .. operator lists all visible commits in the repo, excluding the root (which is never interesting and is shared by all repos).

    "},{"location":"FAQ/#jj-is-said-to-record-the-working-copy-after-jj-log-and-every-other-command-where-can-i-see-these-automatic-saves","title":"jj is said to record the working copy after jj log and every other command. Where can I see these automatic \"saves\"?","text":"

    Indeed, every jj command updates the current \"working-copy\" revision, marked with @ in jj log. You can notice this by how the commit ID of the working copy revision changes when it's updated. Note that, unless you move to another revision (with jj new or jj edit, for example), the change ID will not change.

    If you expected to see a historical view of your working copy changes in the parent-child relationships between commits you can see in jj log, this is simply not what they mean. What you can see in jj log is that after the working copy commit gets amended (after any edit), the commit ID changes.

    You can see the actual history of working copy changes using jj obslog. This will show the history of the commits that were previously the \"working-copy commit\", since the last time the change id of the working copy commit changed. The obsolete changes will be marked as \"hidden\". They are still accessible with any jj command (jj diff, for example), but you will need to use the commit id to refer to hidden commits.

    You can also use jj obslog -r on revisions that were previously the working-copy revisions (or on any other revisions). Use jj obslog -p as an easy way to see the evolution of the commit's contents.

    "},{"location":"FAQ/#can-i-prevent-jujutsu-from-recording-my-unfinished-work-im-not-ready-to-commit-it","title":"Can I prevent Jujutsu from recording my unfinished work? I'm not ready to commit it.","text":"

    Jujutsu automatically records new files in the current working-copy commit and doesn't provide a way to prevent that.

    However, you can easily record intermediate drafts of your work. If you think you might want to go back to the current state of the working-copy commit, simply use jj new. There's no need for the commit to be \"finished\" or even have a description.

    Then future edits will go into a new working-copy commit on top of the now former working-copy commit. Whenever you are happy with another set of edits, use jj squash to amend the previous commit.

    For more options see the next question.

    "},{"location":"FAQ/#can-i-interactively-create-a-new-commit-from-only-some-of-the-changes-in-the-working-copy-like-git-add-p-git-commit-or-hg-commit-i","title":"Can I interactively create a new commit from only some of the changes in the working copy, like git add -p && git commit or hg commit -i?","text":"

    Since the changes are already in the working-copy commit, the equivalent to git add -p && git commit/git commit -p/hg commit -i is to split the working-copy commit with jj split -i (or the practically identical jj commit -i).

    For the equivalent of git commit --amend -p/hg amend -i, use jj squash -i.

    "},{"location":"FAQ/#is-there-something-like-git-rebase-interactive-or-hg-histedit","title":"Is there something like git rebase --interactive or hg histedit?","text":"

    Not yet, you can check this issue for updates.

    To reorder commits, it is for now recommended to rebase commits individually, which may require multiple invocations of jj rebase -r or jj rebase -s.

    To squash or split commits, use jj squash and jj split.

    "},{"location":"FAQ/#how-can-i-keep-my-scratch-files-in-the-repository","title":"How can I keep my scratch files in the repository?","text":"

    You can keep your notes and other scratch files in the repository, if you add a wildcard pattern to either the repo's gitignore or your global gitignore. Something like *.scratch or *.scratchpad should do, after that rename the files you want to keep around to match the pattern.

    If $EDITOR integration is important, something like scratchpad.* may be more helpful, as you can keep the filename extension intact (it matches scratchpad.md, scratchpad.rs and more).

    You can find more details on gitignore files here.

    "},{"location":"FAQ/#how-can-i-keep-local-changes-around-but-not-use-them-for-pull-requests","title":"How can I keep local changes around, but not use them for Pull Requests?","text":"

    In general, you should separate out the changes to their own commit (using e.g. jj split). After that, one possible workflow is to rebase your pending PRs on top of the commit with the local changes. Then, just before pushing to a remote, use jj rebase -s child_of_commit_with_local_changes -d main to move the PRs back on top of main.

    If you have several PRs, you can try jj rebase -s all:commit_with_local_changes+ -d main (note the +) to move them all at once.

    An alternative workflow would be to rebase the commit with local changes on top of the PR you're working on and then do jj new commit_with_local_changes. You'll then need to use jj new --before to create new commits and jj squash --into to move new changes into the correct commits.

    "},{"location":"FAQ/#i-accidentally-changed-files-in-the-wrong-commit-how-do-i-move-the-recent-changes-into-another-commit","title":"I accidentally changed files in the wrong commit, how do I move the recent changes into another commit?","text":"

    Use jj obslog -p to see how your working-copy commit has evolved. Find the commit you want to restore the contents to. Let's say the current commit (with the changes intended for a new commit) are in commit X and the state you wanted is in commit Y. Note the commit id (normally in blue at the end of the line in the log output) of each of them. Now use jj new to create a new working-copy commit, then run jj restore --from Y --to @- to restore the parent commit to the old state, and jj restore --from X to restore the new working-copy commit to the new state.

    "},{"location":"FAQ/#how-do-i-resume-working-on-an-existing-change","title":"How do I resume working on an existing change?","text":"

    There are two ways to resume working on an earlier change: jj new then jj squash, and jj edit. The first is generally recommended, but jj edit can be useful. When you use jj edit, the revision is directly amended with your new changes, making it difficult to tell what exactly you change. You should avoid using jj edit when the revision has a conflict, as you may accidentally break the plain-text annotations on your state without realising.

    To start, use jj new <rev> to create a change based on that earlier revision. Make your edits, then use jj squash to update the earlier revision with those edits. For when you would use git stashing, use jj edit <rev> for expected behaviour. Other workflows may prefer jj edit as well.

    "},{"location":"FAQ/#how-do-i-deal-with-divergent-changes-after-the-change-id","title":"How do I deal with divergent changes ('??' after the change ID)?","text":"

    A divergent change represents a change that has two or more visible commits associated with it. To refer to such commits, you must use their commit ID. Most commonly, the way to resolve this is to abandon the unneeded commits (using jj abandon <commit ID>). If you would like to keep both commits with this change ID, you can jj duplicate one of them before abandoning it.

    Usually, the different commits associated with the divergent change ID should all appear in the log, but due to #2476, they may not. If that happens, you can either use jj log -r 'all()' | grep <change id> or disable the revsets.short-prefixes config option.

    "},{"location":"FAQ/#how-do-i-deal-with-conflicted-branches-after-branch-name","title":"How do I deal with conflicted branches ('??' after branch name)?","text":"

    A conflicted branch is a branch that refers to multiple different commits because jj couldn't fully resolve its desired position. Resolving conflicted branches is usually done by setting the branch to the correct commit using jj branch set <commit ID>.

    Usually, the different commits associated with the conflicted branch should all appear in the log, but if they don't you can use jj branch listto show all the commits associated with it.

    "},{"location":"FAQ/#how-do-i-integrate-jujutsu-with-gerrit","title":"How do I integrate Jujutsu with Gerrit?","text":"

    At the moment you'll need a script, which adds the required fields for Gerrit like the Change-Id footer. Then jj can invoke it via an $EDITOR override in an aliased command. Here's an example from an contributor (look for the jj signoff alias).

    After you have attached the Change-Id: footer to the commit series, you'll have to manually invoke git push of HEAD on the underlying git repository into the remote Gerrit branch refs/for/$BRANCH, where $BRANCH is the base branch you want your changes to go to (e.g., git push origin HEAD:refs/for/main). Using a co-located repo will make the underlying git repo directly accessible from the working directory.

    We hope to integrate with Gerrit natively in the future.

    "},{"location":"branches/","title":"Branches","text":""},{"location":"branches/#introduction","title":"Introduction","text":"

    Branches are named pointers to revisions (just like they are in Git). You can move them without affecting the target revision's identity. Branches automatically move when revisions are rewritten (e.g. by jj rebase). You can pass a branch's name to commands that want a revision as argument. For example, jj co main will check out the revision pointed to by the \"main\" branch. Use jj branch list to list branches and jj branch to create, move, or delete branches. There is currently no concept of an active/current/checked-out branch.

    "},{"location":"branches/#remotes-and-tracked-branches","title":"Remotes and tracked branches","text":"

    Jujutsu records the last seen position of a branch on each remote (just like Git's remote-tracking branches). This record is updated on every jj git fetch and jj git push of the branch. You can refer to the remembered remote branch positions with <branch name>@<remote name>, such as jj new main@origin. jj does not provide a way to manually edit these recorded positions.

    A remote branch can be associated with a local branch of the same name. This is called a tracked remote branch. When you pull a tracked branch from a remote, any changes compared to the current record of the remote's state will be propagated to the corresponding local branch, which will be created if it doesn't exist already.

    Details: how fetch pulls branches

    Let's say you run jj git fetch --remote origin and, during the fetch, jj determines that the remote's \"main\" branch has been moved so that its target is now ahead of the local record in main@origin.

    jj will then update main@origin to the new target. If main@origin is tracked, jj will also apply the change to the local branch main. If the local target has also been moved compared to main@origin (probably because you ran jj branch set main), then the two updates will be merged. If one is ahead of the other, then that target will become the new target. Otherwise, the local branch will become conflicted (see the \"Conflicts\" section below for details).

    Most commands don't show the tracked remote branch if it has the same target as the local branch. The local branch (without @<remote name>) is considered the branch's desired target. Consequently, if you want to update a branch on a remote, you first update the branch locally and then push the update to the remote. If a local branch also exists on some remote but points to a different target there, jj log will show the branch name with an asterisk suffix (e.g. main*). That is meant to remind you that you may want to push the branch to some remote.

    If you want to know the internals of branch tracking, consult the Design Doc.

    "},{"location":"branches/#terminology-summary","title":"Terminology summary","text":"
    • A remote branch is a branch ref on the remote. jj can find out its actual state only when it's actively communicating with the remote. However, jj does store the last-seen position of the remote branch; this is the commit jj show <branch name>@<remote name> would show. This notion is completely analogous to Git's \"remote-tracking branches\".
    • A tracked (remote) branch is defined above. You can make a remote branch tracked with the jj branch track command, for example.
    • A tracking (local) branch is the local branch that jj tries to keep in sync with the tracked remote branch. For example, after jj branch track mybranch@origin, there will be a local branch mybranch that's tracking the remote mybranch@origin branch. A local branch can track a branch of the same name on 0 or more remotes.

    The notion of tracked branches serves a similar function to the Git notion of an \"upstream branch\". Unlike Git, a single local branch can be tracking remote branches on multiple remotes, and the names of the local and remote branches must match.

    "},{"location":"branches/#manually-tracking-a-branch","title":"Manually tracking a branch","text":"

    To track a branch permanently use jj branch track <branch name>@<remote name>. It will now be imported as a local branch until you untrack it or it is deleted on the remote.

    Example:

    $ # List all available branches, as we want our colleague's branch.\n$ jj branch list --all\n$ # Find the branch.\n$ # [...]\n$ # Actually track the branch.\n$ jj branch track <branch name>@<remote name> # Example: jj branch track my-feature@origin\n$ # From this point on, <branch name> will be imported when fetching from <remote name>.\n$ jj git fetch --remote <remote name>\n$ # A local branch <branch name> should have been created or updated while fetching.\n$ jj new <branch name> # Do some local testing, etc.\n
    "},{"location":"branches/#untracking-a-branch","title":"Untracking a branch","text":"

    To stop following a remote branch, you can jj branch untrack it. After that, subsequent fetches of that remote will no longer move the local branch to match the position of the remote branch.

    Example:

    $ # List all local and remote branches.\n$ jj branch list --all\n$ # Find the branch we no longer want to track.\n$ # [...]\n# # Actually untrack it.\n$ jj branch untrack <branch name>@<remote name> # Example: jj branch untrack stuff@origin\n$ # From this point on, this remote branch won't be imported anymore.\n$ # The local branch (e.g. stuff) is unaffected. It may or may not still\n$ # be tracking branches on other remotes (e.g. stuff@upstream).\n
    "},{"location":"branches/#listing-tracked-branches","title":"Listing tracked branches","text":"

    To list tracked branches, you can jj branch list --tracked or jj branch list -t. This command omits local Git-tracking branches by default.

    You can see if a specific branch is tracked with jj branch list --tracked <branch name>.

    "},{"location":"branches/#automatic-tracking-of-branches-gitauto-local-branch-option","title":"Automatic tracking of branches & git.auto-local-branch option","text":"

    There are two situations where jj tracks branches automatically. jj git clone automatically sets up the default remote branch (e.g. main@origin) as tracked. When you push a local branch, the newly created branch on the remote is marked as tracked.

    By default, every other remote branch is marked as \"not tracked\" when it's fetched. If desired, you need to manually jj branch track them. This works well for repositories where multiple people work on a large number of branches.

    The default can be changed by setting the config git.auto-local-branch = true. Then, jj git fetch tracks every newly fetched branch with a local branch. Branches that already existed before the jj git fetch are not affected. This is similar to Mercurial, which fetches all its bookmarks (equivalent to Git branches) by default.

    "},{"location":"branches/#branch-movement","title":"Branch movement","text":"

    Currently Jujutsu automatically moves local branches when these conditions are met:

    • When a commit has been rewritten (e.g, when you rebase) branches and the working-copy will move along with it.
    • When a commit has been abandoned, all associated branches will be moved to its parent(s). If a working copy was pointing to the abandoned commit, then a new working-copy commit will be created on top of the parent(s).

    You could describe the movement as following along the change-id of the current branch commit, even if it isn't entirely accurate.

    "},{"location":"branches/#conflicts","title":"Conflicts","text":"

    Branches can end up in a conflicted state. When that happens, jj status will include information about the conflicted branches (and instructions for how to mitigate it). jj branch list will have details. jj log will show the branch name with a question mark suffix (e.g. main?) on each of the conflicted branch's potential target revisions. Using the branch name to look up a revision will resolve to all potential targets. That means that jj co main will error out, complaining that the revset resolved to multiple revisions.

    Both local branches (e.g. main) and the remote branch (e.g. main@origin) can have conflicts. Both can end up in that state if concurrent operations were run in the repo. The local branch more typically becomes conflicted because it was updated both locally and on a remote.

    To resolve a conflicted state in a local branch (e.g. main), you can move the branch to the desired target with jj branch. You may want to first either merge the conflicted targets with jj merge, or you may want to rebase one side on top of the other with jj rebase.

    To resolve a conflicted state in a remote branch (e.g. main@origin), simply pull from the remote (e.g. jj git fetch). The conflict resolution will also propagate to the local branch (which was presumably also conflicted).

    "},{"location":"cli-reference/","title":"CLI Reference","text":"

    Warning

    This CLI reference is experimental. It is automatically generated, but does not match the jj help output exactly.

    "},{"location":"cli-reference/#command-line-help-for-jj","title":"Command-Line Help for jj","text":"

    This document contains the help content for the jj command-line program.

    Command Overview:

    • jj\u21b4
    • jj abandon\u21b4
    • jj backout\u21b4
    • jj branch\u21b4
    • jj branch create\u21b4
    • jj branch delete\u21b4
    • jj branch forget\u21b4
    • jj branch list\u21b4
    • jj branch rename\u21b4
    • jj branch set\u21b4
    • jj branch track\u21b4
    • jj branch untrack\u21b4
    • jj cat\u21b4
    • jj chmod\u21b4
    • jj commit\u21b4
    • jj config\u21b4
    • jj config list\u21b4
    • jj config get\u21b4
    • jj config set\u21b4
    • jj config edit\u21b4
    • jj config path\u21b4
    • jj describe\u21b4
    • jj diff\u21b4
    • jj diffedit\u21b4
    • jj duplicate\u21b4
    • jj edit\u21b4
    • jj files\u21b4
    • jj git\u21b4
    • jj git remote\u21b4
    • jj git remote add\u21b4
    • jj git remote remove\u21b4
    • jj git remote rename\u21b4
    • jj git remote list\u21b4
    • jj git init\u21b4
    • jj git fetch\u21b4
    • jj git clone\u21b4
    • jj git push\u21b4
    • jj git import\u21b4
    • jj git export\u21b4
    • jj init\u21b4
    • jj interdiff\u21b4
    • jj log\u21b4
    • jj move\u21b4
    • jj new\u21b4
    • jj next\u21b4
    • jj obslog\u21b4
    • jj operation\u21b4
    • jj operation abandon\u21b4
    • jj operation log\u21b4
    • jj operation undo\u21b4
    • jj operation restore\u21b4
    • jj prev\u21b4
    • jj rebase\u21b4
    • jj resolve\u21b4
    • jj restore\u21b4
    • jj root\u21b4
    • jj show\u21b4
    • jj sparse\u21b4
    • jj sparse list\u21b4
    • jj sparse set\u21b4
    • jj sparse reset\u21b4
    • jj sparse edit\u21b4
    • jj split\u21b4
    • jj squash\u21b4
    • jj status\u21b4
    • jj tag\u21b4
    • jj tag list\u21b4
    • jj util\u21b4
    • jj util completion\u21b4
    • jj util gc\u21b4
    • jj util mangen\u21b4
    • jj util markdown-help\u21b4
    • jj util config-schema\u21b4
    • jj undo\u21b4
    • jj unsquash\u21b4
    • jj untrack\u21b4
    • jj version\u21b4
    • jj workspace\u21b4
    • jj workspace add\u21b4
    • jj workspace forget\u21b4
    • jj workspace list\u21b4
    • jj workspace root\u21b4
    • jj workspace update-stale\u21b4
    "},{"location":"cli-reference/#jj","title":"jj","text":"

    Jujutsu (An experimental VCS)

    To get started, see the tutorial at https://github.com/martinvonz/jj/blob/main/docs/tutorial.md.

    Usage: jj [OPTIONS] [COMMAND]

    "},{"location":"cli-reference/#subcommands","title":"Subcommands:","text":"
    • abandon \u2014 Abandon a revision
    • backout \u2014 Apply the reverse of a revision on top of another revision
    • branch \u2014 Manage branches
    • cat \u2014 Print contents of a file in a revision
    • chmod \u2014 Sets or removes the executable bit for paths in the repo
    • commit \u2014 Update the description and create a new change on top
    • config \u2014 Manage config options
    • describe \u2014 Update the change description or other metadata
    • diff \u2014 Compare file contents between two revisions
    • diffedit \u2014 Touch up the content changes in a revision with a diff editor
    • duplicate \u2014 Create a new change with the same content as an existing one
    • edit \u2014 Sets the specified revision as the working-copy revision
    • files \u2014 List files in a revision
    • git \u2014 Commands for working with the underlying Git repo
    • init \u2014 Create a new repo in the given directory
    • interdiff \u2014 Compare the changes of two commits
    • log \u2014 Show revision history
    • move \u2014 Move changes from one revision into another
    • new \u2014 Create a new, empty change and (by default) edit it in the working copy
    • next \u2014 Move the working-copy commit to the child revision
    • obslog \u2014 Show how a change has evolved
    • operation \u2014 Commands for working with the operation log
    • prev \u2014 Move the working-copy commit to the parent revision
    • rebase \u2014 Move revisions to different parent(s)
    • resolve \u2014 Resolve a conflicted file with an external merge tool
    • restore \u2014 Restore paths from another revision
    • root \u2014 Show the current workspace root directory
    • show \u2014 Show commit description and changes in a revision
    • sparse \u2014 Manage which paths from the working-copy commit are present in the working copy
    • split \u2014 Split a revision in two
    • squash \u2014 Move changes from a revision into another revision
    • status \u2014 Show high-level repo status
    • tag \u2014 Manage tags
    • util \u2014 Infrequently used commands such as for generating shell completions
    • undo \u2014 Undo an operation (shortcut for jj op undo)
    • unsquash \u2014 Move changes from a revision's parent into the revision
    • untrack \u2014 Stop tracking specified paths in the working copy
    • version \u2014 Display version information
    • workspace \u2014 Commands for working with workspaces
    "},{"location":"cli-reference/#options","title":"Options:","text":"
    • -R, --repository <REPOSITORY> \u2014 Path to repository to operate on
    • --ignore-working-copy \u2014 Don't snapshot the working copy, and don't update it

      Possible values: true, false

    • --at-operation <AT_OPERATION> \u2014 Operation to load the repo at

      Default value: @

    • --debug \u2014 Enable debug logging

      Possible values: true, false

    • --color <WHEN> \u2014 When to colorize output (always, never, auto)

    • --quiet \u2014 Silence non-primary command output

      Possible values: true, false

    • --no-pager \u2014 Disable the pager

      Possible values: true, false

    • --config-toml <TOML> \u2014 Additional configuration options (can be repeated)

    "},{"location":"cli-reference/#jj-abandon","title":"jj abandon","text":"

    Abandon a revision

    Abandon a revision, rebasing descendants onto its parent(s). The behavior is similar to jj restore --changes-in; the difference is that jj abandon gives you a new change, while jj restore updates the existing change.

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj abandon [OPTIONS] [REVISIONS]...

    "},{"location":"cli-reference/#arguments","title":"Arguments:","text":"
    • <REVISIONS> \u2014 The revision(s) to abandon

      Default value: @

    "},{"location":"cli-reference/#options_1","title":"Options:","text":"
    • -s, --summary \u2014 Do not print every abandoned commit on a separate line

      Possible values: true, false

    • -r \u2014 Ignored (but lets you pass -r for consistency with other commands)

    "},{"location":"cli-reference/#jj-backout","title":"jj backout","text":"

    Apply the reverse of a revision on top of another revision

    Usage: jj backout [OPTIONS]

    "},{"location":"cli-reference/#options_2","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The revision to apply the reverse of

      Default value: @

    • -d, --destination <DESTINATION> \u2014 The revision to apply the reverse changes on top of

      Default value: @

    "},{"location":"cli-reference/#jj-branch","title":"jj branch","text":"

    Manage branches.

    For information about branches, see https://github.com/martinvonz/jj/blob/main/docs/branches.md.

    Usage: jj branch <COMMAND>

    "},{"location":"cli-reference/#subcommands_1","title":"Subcommands:","text":"
    • create \u2014 Create a new branch
    • delete \u2014 Delete an existing branch and propagate the deletion to remotes on the next push
    • forget \u2014 Forget everything about a branch, including its local and remote targets
    • list \u2014 List branches and their targets
    • rename \u2014 Rename old branch name to new branch name
    • set \u2014 Update an existing branch to point to a certain commit
    • track \u2014 Start tracking given remote branches
    • untrack \u2014 Stop tracking given remote branches
    "},{"location":"cli-reference/#jj-branch-create","title":"jj branch create","text":"

    Create a new branch

    Usage: jj branch create [OPTIONS] <NAMES>...

    "},{"location":"cli-reference/#arguments_1","title":"Arguments:","text":"
    • <NAMES> \u2014 The branches to create
    "},{"location":"cli-reference/#options_3","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The branch's target revision
    "},{"location":"cli-reference/#jj-branch-delete","title":"jj branch delete","text":"

    Delete an existing branch and propagate the deletion to remotes on the next push

    Usage: jj branch delete [NAMES]...

    "},{"location":"cli-reference/#arguments_2","title":"Arguments:","text":"
    • <NAMES> \u2014 The branches to delete
    "},{"location":"cli-reference/#options_4","title":"Options:","text":"
    • --glob <GLOB> \u2014 Deprecated. Please prefix the pattern with glob: instead
    "},{"location":"cli-reference/#jj-branch-forget","title":"jj branch forget","text":"

    Forget everything about a branch, including its local and remote targets.

    A forgotten branch will not impact remotes on future pushes. It will be recreated on future pulls if it still exists in the remote.

    Usage: jj branch forget [NAMES]...

    "},{"location":"cli-reference/#arguments_3","title":"Arguments:","text":"
    • <NAMES> \u2014 The branches to forget
    "},{"location":"cli-reference/#options_5","title":"Options:","text":"
    • --glob <GLOB> \u2014 Deprecated. Please prefix the pattern with glob: instead
    "},{"location":"cli-reference/#jj-branch-list","title":"jj branch list","text":"

    List branches and their targets

    By default, a tracking remote branch will be included only if its target is different from the local target. A non-tracking remote branch won't be listed. For a conflicted branch (both local and remote), old target revisions are preceded by a \"-\" and new target revisions are preceded by a \"+\".

    For information about branches, see https://github.com/martinvonz/jj/blob/main/docs/branches.md.

    Usage: jj branch list [OPTIONS] [NAMES]...

    "},{"location":"cli-reference/#arguments_4","title":"Arguments:","text":"
    • <NAMES> \u2014 Show branches whose local name matches
    "},{"location":"cli-reference/#options_6","title":"Options:","text":"
    • -a, --all-remotes \u2014 Show all tracking and non-tracking remote branches including the ones whose targets are synchronized with the local branches

      Possible values: true, false

    • -t, --tracked \u2014 Show remote tracked branches only. Omits local Git-tracking branches by default

      Possible values: true, false

    • -c, --conflicted \u2014 Show conflicted branches only

      Possible values: true, false

    • -r, --revisions <REVISIONS> \u2014 Show branches whose local targets are in the given revisions

    "},{"location":"cli-reference/#jj-branch-rename","title":"jj branch rename","text":"

    Rename old branch name to new branch name.

    The new branch name points at the same commit as the old branch name.

    Usage: jj branch rename <OLD> <NEW>

    "},{"location":"cli-reference/#arguments_5","title":"Arguments:","text":"
    • <OLD> \u2014 The old name of the branch
    • <NEW> \u2014 The new name of the branch
    "},{"location":"cli-reference/#jj-branch-set","title":"jj branch set","text":"

    Update an existing branch to point to a certain commit

    Usage: jj branch set [OPTIONS] <NAMES>...

    "},{"location":"cli-reference/#arguments_6","title":"Arguments:","text":"
    • <NAMES> \u2014 The branches to update
    "},{"location":"cli-reference/#options_7","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The branch's target revision
    • -B, --allow-backwards \u2014 Allow moving the branch backwards or sideways

      Possible values: true, false

    "},{"location":"cli-reference/#jj-branch-track","title":"jj branch track","text":"

    Start tracking given remote branches

    A tracking remote branch will be imported as a local branch of the same name. Changes to it will propagate to the existing local branch on future pulls.

    Usage: jj branch track <BRANCH@REMOTE>...

    "},{"location":"cli-reference/#arguments_7","title":"Arguments:","text":"
    • <BRANCH@REMOTE> \u2014 Remote branches to track
    "},{"location":"cli-reference/#jj-branch-untrack","title":"jj branch untrack","text":"

    Stop tracking given remote branches

    A non-tracking remote branch is just a pointer to the last-fetched remote branch. It won't be imported as a local branch on future pulls.

    Usage: jj branch untrack <BRANCH@REMOTE>...

    "},{"location":"cli-reference/#arguments_8","title":"Arguments:","text":"
    • <BRANCH@REMOTE> \u2014 Remote branches to untrack
    "},{"location":"cli-reference/#jj-cat","title":"jj cat","text":"

    Print contents of a file in a revision

    Usage: jj cat [OPTIONS] <PATH>

    "},{"location":"cli-reference/#arguments_9","title":"Arguments:","text":"
    • <PATH> \u2014 The file to print
    "},{"location":"cli-reference/#options_8","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The revision to get the file contents from

      Default value: @

    "},{"location":"cli-reference/#jj-chmod","title":"jj chmod","text":"

    Sets or removes the executable bit for paths in the repo

    Unlike the POSIX chmod, jj chmod also works on Windows, on conflicted files, and on arbitrary revisions.

    Usage: jj chmod [OPTIONS] <MODE> <PATHS>...

    "},{"location":"cli-reference/#arguments_10","title":"Arguments:","text":"
    • <MODE>

      Possible values:

      • n: Make a path non-executable (alias: normal)
      • x: Make a path executable (alias: executable)
    • <PATHS> \u2014 Paths to change the executable bit for

    "},{"location":"cli-reference/#options_9","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The revision to update

      Default value: @

    "},{"location":"cli-reference/#jj-commit","title":"jj commit","text":"

    Update the description and create a new change on top

    Usage: jj commit [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_11","title":"Arguments:","text":"
    • <PATHS> \u2014 Put these paths in the first commit
    "},{"location":"cli-reference/#options_10","title":"Options:","text":"
    • -i, --interactive \u2014 Interactively choose which changes to include in the first commit

      Possible values: true, false

    • --tool <NAME> \u2014 Specify diff editor to be used (implies --interactive)

    • -m, --message <MESSAGE> \u2014 The change description to use (don't open editor)
    "},{"location":"cli-reference/#jj-config","title":"jj config","text":"

    Manage config options

    Operates on jj configuration, which comes from the config file and environment variables.

    For file locations, supported config options, and other details about jj config, see https://github.com/martinvonz/jj/blob/main/docs/config.md.

    Usage: jj config <COMMAND>

    "},{"location":"cli-reference/#subcommands_2","title":"Subcommands:","text":"
    • list \u2014 List variables set in config file, along with their values
    • get \u2014 Get the value of a given config option.
    • set \u2014 Update config file to set the given option to a given value
    • edit \u2014 Start an editor on a jj config file
    • path \u2014 Print the path to the config file
    "},{"location":"cli-reference/#jj-config-list","title":"jj config list","text":"

    List variables set in config file, along with their values

    Usage: jj config list [OPTIONS] [NAME]

    "},{"location":"cli-reference/#arguments_12","title":"Arguments:","text":"
    • <NAME> \u2014 An optional name of a specific config option to look up
    "},{"location":"cli-reference/#options_11","title":"Options:","text":"
    • --include-defaults \u2014 Whether to explicitly include built-in default values in the list

      Possible values: true, false

    • --include-overridden \u2014 Allow printing overridden values

      Possible values: true, false

    • --user \u2014 Target the user-level config

      Possible values: true, false

    • --repo \u2014 Target the repo-level config

      Possible values: true, false

    • -T, --template <TEMPLATE> \u2014 Render each variable using the given template

    "},{"location":"cli-reference/#jj-config-get","title":"jj config get","text":"

    Get the value of a given config option.

    Unlike jj config list, the result of jj config get is printed without extra formatting and therefore is usable in scripting. For example:

    $ jj config list user.name user.name=\"Martin von Zweigbergk\" $ jj config get user.name Martin von Zweigbergk

    Usage: jj config get <NAME>

    "},{"location":"cli-reference/#arguments_13","title":"Arguments:","text":"
    • <NAME>
    "},{"location":"cli-reference/#jj-config-set","title":"jj config set","text":"

    Update config file to set the given option to a given value

    Usage: jj config set <--user|--repo> <NAME> <VALUE>

    "},{"location":"cli-reference/#arguments_14","title":"Arguments:","text":"
    • <NAME>
    • <VALUE>
    "},{"location":"cli-reference/#options_12","title":"Options:","text":"
    • --user \u2014 Target the user-level config

      Possible values: true, false

    • --repo \u2014 Target the repo-level config

      Possible values: true, false

    "},{"location":"cli-reference/#jj-config-edit","title":"jj config edit","text":"

    Start an editor on a jj config file.

    Creates the file if it doesn't already exist regardless of what the editor does.

    Usage: jj config edit <--user|--repo>

    "},{"location":"cli-reference/#options_13","title":"Options:","text":"
    • --user \u2014 Target the user-level config

      Possible values: true, false

    • --repo \u2014 Target the repo-level config

      Possible values: true, false

    "},{"location":"cli-reference/#jj-config-path","title":"jj config path","text":"

    Print the path to the config file

    A config file at that path may or may not exist.

    See jj config edit if you'd like to immediately edit the file.

    Usage: jj config path <--user|--repo>

    "},{"location":"cli-reference/#options_14","title":"Options:","text":"
    • --user \u2014 Target the user-level config

      Possible values: true, false

    • --repo \u2014 Target the repo-level config

      Possible values: true, false

    "},{"location":"cli-reference/#jj-describe","title":"jj describe","text":"

    Update the change description or other metadata

    Starts an editor to let you edit the description of a change. The editor will be $EDITOR, or pico if that's not defined (Notepad on Windows).

    Usage: jj describe [OPTIONS] [REVISION]

    "},{"location":"cli-reference/#arguments_15","title":"Arguments:","text":"
    • <REVISION> \u2014 The revision whose description to edit

      Default value: @

    "},{"location":"cli-reference/#options_15","title":"Options:","text":"
    • -r \u2014 Ignored (but lets you pass -r for consistency with other commands)

      Possible values: true, false

    • -m, --message <MESSAGE> \u2014 The change description to use (don't open editor)

    • --stdin \u2014 Read the change description from stdin

      Possible values: true, false

    • --no-edit \u2014 Don't open an editor

      Possible values: true, false

    • --reset-author \u2014 Reset the author to the configured user

      Possible values: true, false

    "},{"location":"cli-reference/#jj-diff","title":"jj diff","text":"

    Compare file contents between two revisions

    With the -r option, which is the default, shows the changes compared to the parent revision. If there are several parent revisions (i.e., the given revision is a merge), then they will be merged and the changes from the result to the given revision will be shown.

    With the --from and/or --to options, shows the difference from/to the given revisions. If either is left out, it defaults to the working-copy commit. For example, jj diff --from main shows the changes from \"main\" (perhaps a branch name) to the working-copy commit.

    Usage: jj diff [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_16","title":"Arguments:","text":"
    • <PATHS> \u2014 Restrict the diff to these paths
    "},{"location":"cli-reference/#options_16","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 Show changes in this revision, compared to its parent(s)
    • --from <FROM> \u2014 Show changes from this revision
    • --to <TO> \u2014 Show changes to this revision
    • -s, --summary \u2014 For each path, show only whether it was modified, added, or deleted

      Possible values: true, false

    • --stat \u2014 Show a histogram of the changes

      Possible values: true, false

    • --types \u2014 For each path, show only its type before and after

      Possible values: true, false

    • --git \u2014 Show a Git-format diff

      Possible values: true, false

    • --color-words \u2014 Show a word-level diff with changes indicated only by color

      Possible values: true, false

    • --tool <TOOL> \u2014 Generate diff by external command

    • --context <CONTEXT> \u2014 Number of lines of context to show
    "},{"location":"cli-reference/#jj-diffedit","title":"jj diffedit","text":"

    Touch up the content changes in a revision with a diff editor

    With the -r option, which is the default, starts a diff editor (meld by default) on the changes in the revision.

    With the --from and/or --to options, starts a diff editor comparing the \"from\" revision to the \"to\" revision.

    Edit the right side of the diff until it looks the way you want. Once you close the editor, the revision specified with -r or --to will be updated. Descendants will be rebased on top as usual, which may result in conflicts.

    See jj restore if you want to move entire files from one revision to another. See jj squash -i or jj unsquash -i if you instead want to move changes into or out of the parent revision.

    Usage: jj diffedit [OPTIONS]

    "},{"location":"cli-reference/#options_17","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The revision to touch up. Defaults to @ if neither --to nor --from are specified
    • --from <FROM> \u2014 Show changes from this revision. Defaults to @ if --to is specified
    • --to <TO> \u2014 Edit changes in this revision. Defaults to @ if --from is specified
    • --tool <NAME> \u2014 Specify diff editor to be used
    "},{"location":"cli-reference/#jj-duplicate","title":"jj duplicate","text":"

    Create a new change with the same content as an existing one

    Usage: jj duplicate [REVISIONS]...

    "},{"location":"cli-reference/#arguments_17","title":"Arguments:","text":"
    • <REVISIONS> \u2014 The revision(s) to duplicate

      Default value: @

    "},{"location":"cli-reference/#options_18","title":"Options:","text":"
    • -r \u2014 Ignored (but lets you pass -r for consistency with other commands)
    "},{"location":"cli-reference/#jj-edit","title":"jj edit","text":"

    Sets the specified revision as the working-copy revision

    Note: it is generally recommended to instead use jj new and jj squash.

    For more information, see https://martinvonz.github.io/jj/latest/FAQ#how-do-i-resume-working-on-an-existing-change

    Usage: jj edit <REVISION>

    "},{"location":"cli-reference/#arguments_18","title":"Arguments:","text":"
    • <REVISION> \u2014 The commit to edit
    "},{"location":"cli-reference/#options_19","title":"Options:","text":"
    • -r \u2014 Ignored (but lets you pass -r for consistency with other commands)

      Possible values: true, false

    "},{"location":"cli-reference/#jj-files","title":"jj files","text":"

    List files in a revision

    Usage: jj files [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_19","title":"Arguments:","text":"
    • <PATHS> \u2014 Only list files matching these prefixes (instead of all files)
    "},{"location":"cli-reference/#options_20","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 The revision to list files in

      Default value: @

    "},{"location":"cli-reference/#jj-git","title":"jj git","text":"

    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.

    Usage: jj git <COMMAND>

    "},{"location":"cli-reference/#subcommands_3","title":"Subcommands:","text":"
    • remote \u2014 Manage Git remotes
    • init \u2014 Create a new Git backed repo
    • fetch \u2014 Fetch from a Git remote
    • clone \u2014 Create a new repo backed by a clone of a Git repo
    • push \u2014 Push to a Git remote
    • import \u2014 Update repo with changes made in the underlying Git repo
    • export \u2014 Update the underlying Git repo with changes made in the repo
    "},{"location":"cli-reference/#jj-git-remote","title":"jj git remote","text":"

    Manage Git remotes

    The Git repo will be a bare git repo stored inside the .jj/ directory.

    Usage: jj git remote <COMMAND>

    "},{"location":"cli-reference/#subcommands_4","title":"Subcommands:","text":"
    • add \u2014 Add a Git remote
    • remove \u2014 Remove a Git remote and forget its branches
    • rename \u2014 Rename a Git remote
    • list \u2014 List Git remotes
    "},{"location":"cli-reference/#jj-git-remote-add","title":"jj git remote add","text":"

    Add a Git remote

    Usage: jj git remote add <REMOTE> <URL>

    "},{"location":"cli-reference/#arguments_20","title":"Arguments:","text":"
    • <REMOTE> \u2014 The remote's name
    • <URL> \u2014 The remote's URL
    "},{"location":"cli-reference/#jj-git-remote-remove","title":"jj git remote remove","text":"

    Remove a Git remote and forget its branches

    Usage: jj git remote remove <REMOTE>

    "},{"location":"cli-reference/#arguments_21","title":"Arguments:","text":"
    • <REMOTE> \u2014 The remote's name
    "},{"location":"cli-reference/#jj-git-remote-rename","title":"jj git remote rename","text":"

    Rename a Git remote

    Usage: jj git remote rename <OLD> <NEW>

    "},{"location":"cli-reference/#arguments_22","title":"Arguments:","text":"
    • <OLD> \u2014 The name of an existing remote
    • <NEW> \u2014 The desired name for old
    "},{"location":"cli-reference/#jj-git-remote-list","title":"jj git remote list","text":"

    List Git remotes

    Usage: jj git remote list

    "},{"location":"cli-reference/#jj-git-init","title":"jj git init","text":"

    Create a new Git backed repo

    Usage: jj git init [OPTIONS] [DESTINATION]

    "},{"location":"cli-reference/#arguments_23","title":"Arguments:","text":"
    • <DESTINATION> \u2014 The destination directory where the jj repo will be created. If the directory does not exist, it will be created. If no directory is diven, the current directory is used

      Default value: .

    "},{"location":"cli-reference/#options_21","title":"Options:","text":"
    • --colocate \u2014 Specifies that the jj repo should also be a valid git repo, allowing the use of both jj and git commands in the same directory

      Possible values: true, false

    • --git-repo <GIT_REPO> \u2014 Specifies a path to an existing git repository to be used as the backing git repo for the newly created jj repo

    "},{"location":"cli-reference/#jj-git-fetch","title":"jj git fetch","text":"

    Fetch from a Git remote

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj git fetch [OPTIONS]

    "},{"location":"cli-reference/#options_22","title":"Options:","text":"
    • -b, --branch <BRANCH> \u2014 Fetch only some of the branches

      Default value: glob:*

    • --remote <remote> \u2014 The remote to fetch from (only named remotes are supported, can be repeated)

    • --all-remotes \u2014 Fetch from all remotes

      Possible values: true, false

    "},{"location":"cli-reference/#jj-git-clone","title":"jj git clone","text":"

    Create a new repo backed by a clone of a Git repo

    The Git repo will be a bare git repo stored inside the .jj/ directory.

    Usage: jj git clone [OPTIONS] <SOURCE> [DESTINATION]

    "},{"location":"cli-reference/#arguments_24","title":"Arguments:","text":"
    • <SOURCE> \u2014 URL or path of the Git repo to clone
    • <DESTINATION> \u2014 The directory to write the Jujutsu repo to
    "},{"location":"cli-reference/#options_23","title":"Options:","text":"
    • --colocate \u2014 Whether or not to colocate the Jujutsu repo with the git repo

      Possible values: true, false

    "},{"location":"cli-reference/#jj-git-push","title":"jj git push","text":"

    Push to a Git remote

    By default, pushes any branches pointing to remote_branches(remote=<remote>)..@. Use --branch to push specific branches. Use --all to push all branches. Use --change to generate branch names based on the change IDs of specific commits.

    Usage: jj git push [OPTIONS]

    "},{"location":"cli-reference/#options_24","title":"Options:","text":"
    • --remote <REMOTE> \u2014 The remote to push to (only named remotes are supported)
    • -b, --branch <BRANCH> \u2014 Push only this branch, or branches matching a pattern (can be repeated)
    • --all \u2014 Push all branches (including deleted branches)

      Possible values: true, false

    • --tracked \u2014 Push all tracked branches (including deleted branches)

      Possible values: true, false

    • --deleted \u2014 Push all deleted branches

      Possible values: true, false

    • -r, --revisions <REVISIONS> \u2014 Push branches pointing to these commits (can be repeated)

    • -c, --change <CHANGE> \u2014 Push this commit by creating a branch based on its change ID (can be repeated)
    • --dry-run \u2014 Only display what will change on the remote

      Possible values: true, false

    "},{"location":"cli-reference/#jj-git-import","title":"jj git import","text":"

    Update repo with changes made in the underlying Git repo

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj git import

    "},{"location":"cli-reference/#jj-git-export","title":"jj git export","text":"

    Update the underlying Git repo with changes made in the repo

    Usage: jj git export

    "},{"location":"cli-reference/#jj-init","title":"jj init","text":"

    Create a new repo in the given directory

    If the given directory does not exist, it will be created. If no directory is given, the current directory is used.

    Usage: jj init [DESTINATION]

    "},{"location":"cli-reference/#arguments_25","title":"Arguments:","text":"
    • <DESTINATION> \u2014 The destination directory

      Default value: .

    "},{"location":"cli-reference/#options_25","title":"Options:","text":"
    • --git \u2014 DEPRECATED: Use jj git init Use the Git backend, creating a jj repo backed by a Git repo

      Possible values: true, false

    • --git-repo <GIT_REPO> \u2014 DEPRECATED: Use jj git init Path to a git repo the jj repo will be backed by

    "},{"location":"cli-reference/#jj-interdiff","title":"jj interdiff","text":"

    Compare the changes of two commits

    This excludes changes from other commits by temporarily rebasing --from onto --to's parents. If you wish to compare the same change across versions, consider jj obslog -p instead.

    Usage: jj interdiff [OPTIONS] <--from <FROM>|--to <TO>> [PATHS]...

    "},{"location":"cli-reference/#arguments_26","title":"Arguments:","text":"
    • <PATHS> \u2014 Restrict the diff to these paths
    "},{"location":"cli-reference/#options_26","title":"Options:","text":"
    • --from <FROM> \u2014 Show changes from this revision
    • --to <TO> \u2014 Show changes to this revision
    • -s, --summary \u2014 For each path, show only whether it was modified, added, or deleted

      Possible values: true, false

    • --stat \u2014 Show a histogram of the changes

      Possible values: true, false

    • --types \u2014 For each path, show only its type before and after

      Possible values: true, false

    • --git \u2014 Show a Git-format diff

      Possible values: true, false

    • --color-words \u2014 Show a word-level diff with changes indicated only by color

      Possible values: true, false

    • --tool <TOOL> \u2014 Generate diff by external command

    • --context <CONTEXT> \u2014 Number of lines of context to show
    "},{"location":"cli-reference/#jj-log","title":"jj log","text":"

    Show revision history

    Renders a graphical view of the project's history, ordered with children before parents. By default, the output only includes mutable revisions, along with some additional revisions for context.

    Spans of revisions that are not included in the graph per --revisions are rendered as a synthetic node labeled \"(elided revisions)\".

    Usage: jj log [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_27","title":"Arguments:","text":"
    • <PATHS> \u2014 Show revisions modifying the given paths
    "},{"location":"cli-reference/#options_27","title":"Options:","text":"
    • -r, --revisions <REVISIONS> \u2014 Which revisions to show. Defaults to the revsets.log setting, or @ | ancestors(immutable_heads().., 2) | trunk() if it is not set
    • --reversed \u2014 Show revisions in the opposite order (older revisions first)

      Possible values: true, false

    • -l, --limit <LIMIT> \u2014 Limit number of revisions to show

    • --no-graph \u2014 Don't show the graph, show a flat list of revisions

      Possible values: true, false

    • -T, --template <TEMPLATE> \u2014 Render each revision using the given template

    • -p, --patch \u2014 Show patch

      Possible values: true, false

    • -s, --summary \u2014 For each path, show only whether it was modified, added, or deleted

      Possible values: true, false

    • --stat \u2014 Show a histogram of the changes

      Possible values: true, false

    • --types \u2014 For each path, show only its type before and after

      Possible values: true, false

    • --git \u2014 Show a Git-format diff

      Possible values: true, false

    • --color-words \u2014 Show a word-level diff with changes indicated only by color

      Possible values: true, false

    • --tool <TOOL> \u2014 Generate diff by external command

    • --context <CONTEXT> \u2014 Number of lines of context to show
    "},{"location":"cli-reference/#jj-move","title":"jj move","text":"

    Move changes from one revision into another

    Use --interactive to move only part of the source revision into the destination. The selected changes (or all the changes in the source revision if not using --interactive) will be moved into the destination. The changes will be removed from the source. If that means that the source is now empty compared to its parent, it will be abandoned. Without --interactive, the source change will always be empty.

    If the source became empty and both the source and destination had a non-empty description, you will be asked for the combined description. If either was empty, then the other one will be used.

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj move [OPTIONS] <--from <FROM>|--to <TO>> [PATHS]...

    "},{"location":"cli-reference/#arguments_28","title":"Arguments:","text":"
    • <PATHS> \u2014 Move only changes to these paths (instead of all paths)
    "},{"location":"cli-reference/#options_28","title":"Options:","text":"
    • -f, --from <FROM> \u2014 Move part of this change into the destination
    • -t, --to <TO> \u2014 Move part of the source into this change
    • -i, --interactive \u2014 Interactively choose which parts to move

      Possible values: true, false

    • --tool <NAME> \u2014 Specify diff editor to be used (implies --interactive)

    "},{"location":"cli-reference/#jj-new","title":"jj new","text":"

    Create a new, empty change and (by default) edit it in the working copy

    By default, jj will edit the new change, making the working copy represent the new commit. This can be avoided with --no-edit.

    Note that you can create a merge commit by specifying multiple revisions as argument. For example, jj new main @ will create a new commit with the main branch and the working copy as parents.

    For more information, see https://github.com/martinvonz/jj/blob/main/docs/working-copy.md.

    Usage: jj new [OPTIONS] [REVISIONS]...

    "},{"location":"cli-reference/#arguments_29","title":"Arguments:","text":"
    • <REVISIONS> \u2014 Parent(s) of the new change

      Default value: @

    "},{"location":"cli-reference/#options_29","title":"Options:","text":"
    • -r \u2014 Ignored (but lets you pass -r for consistency with other commands)
    • -m, --message <MESSAGE> \u2014 The change description to use
    • -L, --allow-large-revsets \u2014 Deprecated. Please prefix the revset with all: instead

      Possible values: true, false

    • --no-edit \u2014 Do not edit the newly created change

      Possible values: true, false

    • --edit \u2014 No-op flag to pair with --no-edit

      Possible values: true, false

    • -A, --insert-after \u2014 Insert the new change between the target commit(s) and their children

      Possible values: true, false

    • -B, --insert-before \u2014 Insert the new change between the target commit(s) and their parents

      Possible values: true, false

    "},{"location":"cli-reference/#jj-next","title":"jj next","text":"

    Move the working-copy commit to the child revision

    The command moves you to the next child in a linear fashion.

    D      D @\n|      |/\nC @ => C\n|/     |\nB      B\n

    If --edit is passed, it will move you directly to the child revision.

    D    D\n|    |\nC    C\n|    |\nB => @\n|    |\n@    A\n\nIf your working-copy commit already has visible children, then `--edit` is\nimplied.\n

    Usage: jj next [OPTIONS] [AMOUNT]

    "},{"location":"cli-reference/#arguments_30","title":"Arguments:","text":"
    • <AMOUNT> \u2014 How many revisions to move forward. By default advances to the next child

      Default value: 1

    "},{"location":"cli-reference/#options_30","title":"Options:","text":"
    • --edit \u2014 Instead of creating a new working-copy commit on top of the target commit (like jj new), edit the target commit directly (like jj edit)

      Possible values: true, false

    "},{"location":"cli-reference/#jj-obslog","title":"jj obslog","text":"

    Show how a change has evolved

    Show how a change has evolved as it's been updated, rebased, etc.

    Usage: jj obslog [OPTIONS]

    "},{"location":"cli-reference/#options_31","title":"Options:","text":"
    • -r, --revision <REVISION>

      Default value: @

    • -l, --limit <LIMIT> \u2014 Limit number of revisions to show

    • --no-graph \u2014 Don't show the graph, show a flat list of revisions

      Possible values: true, false

    • -T, --template <TEMPLATE> \u2014 Render each revision using the given template

    • -p, --patch \u2014 Show patch compared to the previous version of this change

      Possible values: true, false

    • -s, --summary \u2014 For each path, show only whether it was modified, added, or deleted

      Possible values: true, false

    • --stat \u2014 Show a histogram of the changes

      Possible values: true, false

    • --types \u2014 For each path, show only its type before and after

      Possible values: true, false

    • --git \u2014 Show a Git-format diff

      Possible values: true, false

    • --color-words \u2014 Show a word-level diff with changes indicated only by color

      Possible values: true, false

    • --tool <TOOL> \u2014 Generate diff by external command

    • --context <CONTEXT> \u2014 Number of lines of context to show
    "},{"location":"cli-reference/#jj-operation","title":"jj operation","text":"

    Commands for working with the operation log

    For information about the operation log, see https://github.com/martinvonz/jj/blob/main/docs/operation-log.md.

    Usage: jj operation <COMMAND>

    "},{"location":"cli-reference/#subcommands_5","title":"Subcommands:","text":"
    • abandon \u2014 Abandon operation history
    • log \u2014 Show the operation log
    • undo \u2014 Create a new operation that undoes an earlier operation
    • restore \u2014 Create a new operation that restores the repo to an earlier state
    "},{"location":"cli-reference/#jj-operation-abandon","title":"jj operation abandon","text":"

    Abandon operation history

    To discard old operation history, use jj op abandon ..<operation ID>. It will abandon the specified operation and all its ancestors. The descendants will be reparented onto the root operation.

    To discard recent operations, use jj op restore <operation ID> followed by jj op abandon <operation ID>..@-.

    The abandoned operations, commits, and other unreachable objects can later be garbage collected by using jj util gc command.

    Usage: jj operation abandon <OPERATION>

    "},{"location":"cli-reference/#arguments_31","title":"Arguments:","text":"
    • <OPERATION> \u2014 The operation or operation range to abandon
    "},{"location":"cli-reference/#jj-operation-log","title":"jj operation log","text":"

    Show the operation log

    Usage: jj operation log [OPTIONS]

    "},{"location":"cli-reference/#options_32","title":"Options:","text":"
    • -l, --limit <LIMIT> \u2014 Limit number of operations to show
    • --no-graph \u2014 Don't show the graph, show a flat list of operations

      Possible values: true, false

    • -T, --template <TEMPLATE> \u2014 Render each operation using the given template

    "},{"location":"cli-reference/#jj-operation-undo","title":"jj operation undo","text":"

    Create a new operation that undoes an earlier operation

    This undoes an individual operation by applying the inverse of the operation.

    Usage: jj operation undo [OPTIONS] [OPERATION]

    "},{"location":"cli-reference/#arguments_32","title":"Arguments:","text":"
    • <OPERATION> \u2014 The operation to undo

      Default value: @

    "},{"location":"cli-reference/#options_33","title":"Options:","text":"
    • --what <WHAT> \u2014 What portions of the local state to restore (can be repeated)

      Default values: repo, remote-tracking

      Possible values:

      • repo: The jj repo state and local branches
      • remote-tracking: The remote-tracking branches. Do not restore these if you'd like to push after the undo
    "},{"location":"cli-reference/#jj-operation-restore","title":"jj operation restore","text":"

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

    This restores the repo to the state at the specified operation, effectively undoing all later operations. It does so by creating a new operation.

    Usage: jj operation restore [OPTIONS] <OPERATION>

    "},{"location":"cli-reference/#arguments_33","title":"Arguments:","text":"
    • <OPERATION> \u2014 The operation to restore to
    "},{"location":"cli-reference/#options_34","title":"Options:","text":"
    • --what <WHAT> \u2014 What portions of the local state to restore (can be repeated)

      Default values: repo, remote-tracking

      Possible values:

      • repo: The jj repo state and local branches
      • remote-tracking: The remote-tracking branches. Do not restore these if you'd like to push after the undo
    "},{"location":"cli-reference/#jj-prev","title":"jj prev","text":"

    Move the working-copy commit to the parent revision

    The command moves you to the parent in a linear fashion.

    D @  D\n|/   |\nA => A @\n|    |/\nB    B\n

    If --edit is passed, it will move the working copy commit directly to the parent.

    D @  D\n|/   |\nC => @\n|    |\nB    B\n|    |\nA    A\n\nIf your working-copy commit already has visible children, then `--edit` is\nimplied.\n

    Usage: jj prev [OPTIONS] [AMOUNT]

    "},{"location":"cli-reference/#arguments_34","title":"Arguments:","text":"
    • <AMOUNT> \u2014 How many revisions to move backward. By default moves to the parent

      Default value: 1

    "},{"location":"cli-reference/#options_35","title":"Options:","text":"
    • --edit \u2014 Edit the parent directly, instead of moving the working-copy commit

      Possible values: true, false

    "},{"location":"cli-reference/#jj-rebase","title":"jj rebase","text":"

    Move revisions to different parent(s)

    There are three different ways of specifying which revisions to rebase: -b to rebase a whole branch, -s to rebase a revision and its descendants, and -r to rebase a single commit. If none of them is specified, it defaults to -b @.

    With -s, the command rebases the specified revision and its descendants onto the destination. For example, jj rebase -s M -d O would transform your history like this (letters followed by an apostrophe are post-rebase versions):

    O           N'\n|           |\n| N         M'\n| |         |\n| M         O\n| |    =>   |\n| | L       | L\n| |/        | |\n| K         | K\n|/          |/\nJ           J\n

    With -b, the command rebases the whole \"branch\" containing the specified revision. A \"branch\" is the set of commits that includes:

    • the specified revision and ancestors that are not also ancestors of the destination
    • all descendants of those commits

    In other words, jj rebase -b X -d Y rebases commits in the revset (Y..X):: (which is equivalent to jj rebase -s 'roots(Y..X)' -d Y for a single root). For example, either jj rebase -b L -d O or jj rebase -b M -d O would transform your history like this (because L and M are on the same \"branch\", relative to the destination):

    O           N'\n|           |\n| N         M'\n| |         |\n| M         | L'\n| |    =>   |/\n| | L       K'\n| |/        |\n| K         O\n|/          |\nJ           J\n

    With -r, the command rebases only the specified revision onto the destination. Any \"hole\" left behind will be filled by rebasing descendants onto the specified revision's parent(s). For example, jj rebase -r K -d M would transform your history like this:

    M          K'\n|          |\n| L        M\n| |   =>   |\n| K        | L'\n|/         |/\nJ          J\n

    Note that you can create a merge commit by repeating the -d argument. For example, if you realize that commit L actually depends on commit M in order to work (in addition to its current parent K), you can run jj rebase -s L -d K -d M:

    M          L'\n|          |\\\n| L        M |\n| |   =>   | |\n| K        | K\n|/         |/\nJ          J\n

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj rebase [OPTIONS] --destination <DESTINATION>

    "},{"location":"cli-reference/#options_36","title":"Options:","text":"
    • -b, --branch <BRANCH> \u2014 Rebase the whole branch relative to destination's ancestors (can be repeated)
    • -s, --source <SOURCE> \u2014 Rebase specified revision(s) together with their trees of descendants (can be repeated)
    • -r, --revision <REVISION> \u2014 Rebase only this revision, rebasing descendants onto this revision's parent(s)
    • -d, --destination <DESTINATION> \u2014 The revision(s) to rebase onto (can be repeated to create a merge commit)
    • --skip-empty \u2014 If true, when rebasing would produce an empty commit, the commit is abandoned. It will not be abandoned if it was already empty before the rebase. Will never skip merge commits with multiple non-empty parents

      Possible values: true, false

    • -L, --allow-large-revsets \u2014 Deprecated. Please prefix the revset with all: instead

      Possible values: true, false

    "},{"location":"cli-reference/#jj-resolve","title":"jj resolve","text":"

    Resolve a conflicted file with an external merge tool

    Only conflicts that can be resolved with a 3-way merge are supported. See docs for merge tool configuration instructions.

    Note that conflicts can also be resolved without using this command. You may edit the conflict markers in the conflicted file directly with a text editor.

    Usage: jj resolve [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_35","title":"Arguments:","text":"
    • <PATHS> \u2014 Restrict to these paths when searching for a conflict to resolve. We will attempt to resolve the first conflict we can find. You can use the --list argument to find paths to use here
    "},{"location":"cli-reference/#options_37","title":"Options:","text":"
    • -r, --revision <REVISION>

      Default value: @

    • -l, --list \u2014 Instead of resolving one conflict, list all the conflicts

      Possible values: true, false

    • --tool <NAME> \u2014 Specify 3-way merge tool to be used

    "},{"location":"cli-reference/#jj-restore","title":"jj restore","text":"

    Restore paths from another revision

    That means that the paths get the same content in the destination (--to) as they had in the source (--from). This is typically used for undoing changes to some paths in the working copy (jj restore <paths>).

    If only one of --from or --to is specified, the other one defaults to the working copy.

    When neither --from nor --to is specified, the command restores into the working copy from its parent(s). jj restore without arguments is similar to jj abandon, except that it leaves an empty revision with its description and other metadata preserved.

    See jj diffedit if you'd like to restore portions of files rather than entire files.

    Usage: jj restore [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_36","title":"Arguments:","text":"
    • <PATHS> \u2014 Restore only these paths (instead of all paths)
    "},{"location":"cli-reference/#options_38","title":"Options:","text":"
    • --from <FROM> \u2014 Revision to restore from (source)
    • --to <TO> \u2014 Revision to restore into (destination)
    • -c, --changes-in <REVISION> \u2014 Undo the changes in a revision as compared to the merge of its parents
    • -r, --revision <REVISION> \u2014 Prints an error. DO NOT USE
    "},{"location":"cli-reference/#jj-root","title":"jj root","text":"

    Show the current workspace root directory

    Usage: jj root

    "},{"location":"cli-reference/#jj-show","title":"jj show","text":"

    Show commit description and changes in a revision

    Usage: jj show [OPTIONS] [REVISION]

    "},{"location":"cli-reference/#arguments_37","title":"Arguments:","text":"
    • <REVISION> \u2014 Show changes in this revision, compared to its parent(s)

      Default value: @

    "},{"location":"cli-reference/#options_39","title":"Options:","text":"
    • -r \u2014 Ignored (but lets you pass -r for consistency with other commands)

      Possible values: true, false

    • -T, --template <TEMPLATE> \u2014 Render a revision using the given template

    • -s, --summary \u2014 For each path, show only whether it was modified, added, or deleted

      Possible values: true, false

    • --stat \u2014 Show a histogram of the changes

      Possible values: true, false

    • --types \u2014 For each path, show only its type before and after

      Possible values: true, false

    • --git \u2014 Show a Git-format diff

      Possible values: true, false

    • --color-words \u2014 Show a word-level diff with changes indicated only by color

      Possible values: true, false

    • --tool <TOOL> \u2014 Generate diff by external command

    • --context <CONTEXT> \u2014 Number of lines of context to show
    "},{"location":"cli-reference/#jj-sparse","title":"jj sparse","text":"

    Manage which paths from the working-copy commit are present in the working copy

    Usage: jj sparse <COMMAND>

    "},{"location":"cli-reference/#subcommands_6","title":"Subcommands:","text":"
    • list \u2014 List the patterns that are currently present in the working copy
    • set \u2014 Update the patterns that are present in the working copy
    • reset \u2014 Reset the patterns to include all files in the working copy
    • edit \u2014 Start an editor to update the patterns that are present in the working copy
    "},{"location":"cli-reference/#jj-sparse-list","title":"jj sparse list","text":"

    List the patterns that are currently present in the working copy

    By default, a newly cloned or initialized repo will have have a pattern matching all files from the repo root. That pattern is rendered as . (a single period).

    Usage: jj sparse list

    "},{"location":"cli-reference/#jj-sparse-set","title":"jj sparse set","text":"

    Update the patterns that are present in the working copy

    For example, if all you need is the README.md and the lib/ directory, use jj sparse set --clear --add README.md --add lib. If you no longer need the lib directory, use jj sparse set --remove lib.

    Usage: jj sparse set [OPTIONS]

    "},{"location":"cli-reference/#options_40","title":"Options:","text":"
    • --add <ADD> \u2014 Patterns to add to the working copy
    • --remove <REMOVE> \u2014 Patterns to remove from the working copy
    • --clear \u2014 Include no files in the working copy (combine with --add)

      Possible values: true, false

    "},{"location":"cli-reference/#jj-sparse-reset","title":"jj sparse reset","text":"

    Reset the patterns to include all files in the working copy

    Usage: jj sparse reset

    "},{"location":"cli-reference/#jj-sparse-edit","title":"jj sparse edit","text":"

    Start an editor to update the patterns that are present in the working copy

    Usage: jj sparse edit

    "},{"location":"cli-reference/#jj-split","title":"jj split","text":"

    Split a revision in two

    Starts a diff editor (meld by default) on the changes in the revision. Edit the right side of the diff until it has the content you want in the first revision. Once you close the editor, your edited content will replace the previous revision. The remaining changes will be put in a new revision on top.

    If the change you split had a description, you will be asked to enter a change description for each commit. If the change did not have a description, the second part will not get a description, and you will be asked for a description only for the first part.

    Usage: jj split [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_38","title":"Arguments:","text":"
    • <PATHS> \u2014 Put these paths in the first commit
    "},{"location":"cli-reference/#options_41","title":"Options:","text":"
    • -i, --interactive \u2014 Interactively choose which parts to split. This is the default if no paths are provided

      Possible values: true, false

    • --tool <NAME> \u2014 Specify diff editor to be used (implies --interactive)

    • -r, --revision <REVISION> \u2014 The revision to split

      Default value: @

    "},{"location":"cli-reference/#jj-squash","title":"jj squash","text":"

    Move changes from a revision into another revision

    With the -r option, moves the changes from the specified revision to the parent revision. Fails if there are several parent revisions (i.e., the given revision is a merge).

    With the --from and/or --into options, moves changes from/to the given revisions. If either is left out, it defaults to the working-copy commit. For example, jj squash --into @-- moves changes from the working-copy commit to the grandparent.

    If, after moving changes out, the source revision is empty compared to its parent(s), it will be abandoned. Without --interactive, the source revision will always be empty.

    If the source became empty and both the source and destination had a non-empty description, you will be asked for the combined description. If either was empty, then the other one will be used.

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj squash [OPTIONS] [PATHS]...

    "},{"location":"cli-reference/#arguments_39","title":"Arguments:","text":"
    • <PATHS> \u2014 Move only changes to these paths (instead of all paths)
    "},{"location":"cli-reference/#options_42","title":"Options:","text":"
    • -r, --revision <REVISION> \u2014 Revision to squash into its parent (default: @)
    • --from <FROM> \u2014 Revision to squash from (default: @)
    • --into <INTO> \u2014 Revision to squash into (default: @)
    • -m, --message <MESSAGE> \u2014 The description to use for squashed revision (don't open editor)
    • -i, --interactive \u2014 Interactively choose which parts to squash

      Possible values: true, false

    • --tool <NAME> \u2014 Specify diff editor to be used (implies --interactive)

    "},{"location":"cli-reference/#jj-status","title":"jj status","text":"

    Show high-level repo status

    This includes:

    • The working copy commit and its (first) parent, and a summary of the changes between them

    • Conflicted branches (see https://github.com/martinvonz/jj/blob/main/docs/branches.md)

    Usage: jj status

    "},{"location":"cli-reference/#jj-tag","title":"jj tag","text":"

    Manage tags

    Usage: jj tag <COMMAND>

    "},{"location":"cli-reference/#subcommands_7","title":"Subcommands:","text":"
    • list \u2014 List tags
    "},{"location":"cli-reference/#jj-tag-list","title":"jj tag list","text":"

    List tags

    Usage: jj tag list [NAMES]...

    "},{"location":"cli-reference/#arguments_40","title":"Arguments:","text":"
    • <NAMES> \u2014 Show tags whose local name matches
    "},{"location":"cli-reference/#jj-util","title":"jj util","text":"

    Infrequently used commands such as for generating shell completions

    Usage: jj util <COMMAND>

    "},{"location":"cli-reference/#subcommands_8","title":"Subcommands:","text":"
    • completion \u2014 Print a command-line-completion script
    • gc \u2014 Run backend-dependent garbage collection
    • mangen \u2014 Print a ROFF (manpage)
    • markdown-help \u2014 Print the CLI help for all subcommands in Markdown
    • config-schema \u2014 Print the JSON schema for the jj TOML config format
    "},{"location":"cli-reference/#jj-util-completion","title":"jj util completion","text":"

    Print a command-line-completion script

    Apply it by running one of these:

    • bash: source <(jj util completion bash)
    • fish: jj util completion fish | source
    • nushell:
      jj util completion nushell | save \"completions-jj.nu\"\nuse \"completions-jj.nu\" *  # Or `source \"completions-jj.nu\"`\n
    • zsh:
      autoload -U compinit\ncompinit\nsource <(jj util completion zsh)\n

    Usage: jj util completion [SHELL]

    "},{"location":"cli-reference/#arguments_41","title":"Arguments:","text":"
    • <SHELL>

      Possible values: bash, elvish, fish, nushell, power-shell, zsh

    "},{"location":"cli-reference/#options_43","title":"Options:","text":"
    • --bash \u2014 Deprecated. Use the SHELL positional argument instead

      Possible values: true, false

    • --fish \u2014 Deprecated. Use the SHELL positional argument instead

      Possible values: true, false

    • --zsh \u2014 Deprecated. Use the SHELL positional argument instead

      Possible values: true, false

    "},{"location":"cli-reference/#jj-util-gc","title":"jj util gc","text":"

    Run backend-dependent garbage collection

    Usage: jj util gc [OPTIONS]

    "},{"location":"cli-reference/#options_44","title":"Options:","text":"
    • --expire <EXPIRE> \u2014 Time threshold
    "},{"location":"cli-reference/#jj-util-mangen","title":"jj util mangen","text":"

    Print a ROFF (manpage)

    Usage: jj util mangen

    "},{"location":"cli-reference/#jj-util-markdown-help","title":"jj util markdown-help","text":"

    Print the CLI help for all subcommands in Markdown

    Usage: jj util markdown-help

    "},{"location":"cli-reference/#jj-util-config-schema","title":"jj util config-schema","text":"

    Print the JSON schema for the jj TOML config format

    Usage: jj util config-schema

    "},{"location":"cli-reference/#jj-undo","title":"jj undo","text":"

    Undo an operation (shortcut for jj op undo)

    Usage: jj undo [OPTIONS] [OPERATION]

    "},{"location":"cli-reference/#arguments_42","title":"Arguments:","text":"
    • <OPERATION> \u2014 The operation to undo

      Default value: @

    "},{"location":"cli-reference/#options_45","title":"Options:","text":"
    • --what <WHAT> \u2014 What portions of the local state to restore (can be repeated)

      Default values: repo, remote-tracking

      Possible values:

      • repo: The jj repo state and local branches
      • remote-tracking: The remote-tracking branches. Do not restore these if you'd like to push after the undo
    "},{"location":"cli-reference/#jj-unsquash","title":"jj unsquash","text":"

    Move changes from a revision's parent into the revision

    After moving the changes out of the parent, the child revision will have the same content state as before. If moving the change out of the parent change made it empty compared to its parent, it will be abandoned. Without --interactive, the parent change will always become empty.

    If the source became empty and both the source and destination had a non-empty description, you will be asked for the combined description. If either was empty, then the other one will be used.

    If a working-copy commit gets abandoned, it will be given a new, empty commit. This is true in general; it is not specific to this command.

    Usage: jj unsquash [OPTIONS]

    "},{"location":"cli-reference/#options_46","title":"Options:","text":"
    • -r, --revision <REVISION>

      Default value: @

    • -i, --interactive \u2014 Interactively choose which parts to unsquash

      Possible values: true, false

    • --tool <NAME> \u2014 Specify diff editor to be used (implies --interactive)

    "},{"location":"cli-reference/#jj-untrack","title":"jj untrack","text":"

    Stop tracking specified paths in the working copy

    Usage: jj untrack <PATHS>...

    "},{"location":"cli-reference/#arguments_43","title":"Arguments:","text":"
    • <PATHS> \u2014 Paths to untrack. They must already be ignored
    "},{"location":"cli-reference/#jj-version","title":"jj version","text":"

    Display version information

    Usage: jj version

    "},{"location":"cli-reference/#jj-workspace","title":"jj workspace","text":"

    Commands for working with workspaces

    Workspaces let you add additional working copies attached to the same repo. A common use case is so you can run a slow build or test in one workspace while you're continuing to write code in another workspace.

    Each workspace has its own working-copy commit. When you have more than one workspace attached to a repo, they are indicated by @<workspace name> in jj log.

    Each workspace also has own sparse patterns.

    Usage: jj workspace <COMMAND>

    "},{"location":"cli-reference/#subcommands_9","title":"Subcommands:","text":"
    • add \u2014 Add a workspace
    • forget \u2014 Stop tracking a workspace's working-copy commit in the repo
    • list \u2014 List workspaces
    • root \u2014 Show the current workspace root directory
    • update-stale \u2014 Update a workspace that has become stale
    "},{"location":"cli-reference/#jj-workspace-add","title":"jj workspace add","text":"

    Add a workspace

    Sparse patterns will be copied over from the current workspace.

    Usage: jj workspace add [OPTIONS] <DESTINATION>

    "},{"location":"cli-reference/#arguments_44","title":"Arguments:","text":"
    • <DESTINATION> \u2014 Where to create the new workspace
    "},{"location":"cli-reference/#options_47","title":"Options:","text":"
    • --name <NAME> \u2014 A name for the workspace
    • -r, --revision <REVISION> \u2014 A list of parent revisions for the working-copy commit of the newly created workspace. You may specify nothing, or any number of parents
    "},{"location":"cli-reference/#jj-workspace-forget","title":"jj workspace forget","text":"

    Stop tracking a workspace's working-copy commit in the repo

    The workspace will not be touched on disk. It can be deleted from disk before or after running this command.

    Usage: jj workspace forget [WORKSPACES]...

    "},{"location":"cli-reference/#arguments_45","title":"Arguments:","text":"
    • <WORKSPACES> \u2014 Names of the workspaces to forget. By default, forgets only the current workspace
    "},{"location":"cli-reference/#jj-workspace-list","title":"jj workspace list","text":"

    List workspaces

    Usage: jj workspace list

    "},{"location":"cli-reference/#jj-workspace-root","title":"jj workspace root","text":"

    Show the current workspace root directory

    Usage: jj workspace root

    "},{"location":"cli-reference/#jj-workspace-update-stale","title":"jj workspace update-stale","text":"

    Update a workspace that has become stale

    For information about stale working copies, see https://github.com/martinvonz/jj/blob/main/docs/working-copy.md.

    Usage: jj workspace update-stale

    This document was generated automatically by clap-markdown.

    "},{"location":"code-of-conduct/","title":"Contributor Covenant Code of Conduct","text":""},{"location":"code-of-conduct/#our-pledge","title":"Our Pledge","text":"

    We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.

    We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

    "},{"location":"code-of-conduct/#our-standards","title":"Our Standards","text":"

    Examples of behavior that contributes to a positive environment for our community include:

    • Demonstrating empathy and kindness toward other people
    • Being respectful of differing opinions, viewpoints, and experiences
    • Giving and gracefully accepting constructive feedback
    • Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
    • Focusing on what is best not just for us as individuals, but for the overall community

    Examples of unacceptable behavior include:

    • The use of sexualized language or imagery, and sexual attention or advances of any kind
    • Trolling, insulting or derogatory comments, and personal or political attacks
    • Public or private harassment
    • Publishing others' private information, such as a physical or email address, without their explicit permission
    • Other conduct which could reasonably be considered inappropriate in a professional setting
    "},{"location":"code-of-conduct/#enforcement-responsibilities","title":"Enforcement Responsibilities","text":"

    Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

    Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

    "},{"location":"code-of-conduct/#scope","title":"Scope","text":"

    This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

    "},{"location":"code-of-conduct/#enforcement","title":"Enforcement","text":"

    Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at two or more of jaraco@jaraco.com, avamsi07@gmail.com, me@waleedkhan.name, and opensource@google.com. All complaints will be reviewed and investigated promptly and fairly.

    All community leaders are obligated to respect the privacy and security of the reporter of any incident.

    "},{"location":"code-of-conduct/#enforcement-guidelines","title":"Enforcement Guidelines","text":"

    Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

    "},{"location":"code-of-conduct/#1-correction","title":"1. Correction","text":"

    Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

    Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

    "},{"location":"code-of-conduct/#2-warning","title":"2. Warning","text":"

    Community Impact: A violation through a single incident or series of actions.

    Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

    "},{"location":"code-of-conduct/#3-temporary-ban","title":"3. Temporary Ban","text":"

    Community Impact: A serious violation of community standards, including sustained inappropriate behavior.

    Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

    "},{"location":"code-of-conduct/#4-permanent-ban","title":"4. Permanent Ban","text":"

    Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

    Consequence: A permanent ban from any sort of public interaction within the community.

    "},{"location":"code-of-conduct/#attribution","title":"Attribution","text":"

    This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.

    Community Impact Guidelines were inspired by Mozilla's code of conduct enforcement ladder.

    For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

    "},{"location":"config/","title":"Configuration","text":"

    These are the config settings available to jj/Jujutsu.

    "},{"location":"config/#config-files-and-toml","title":"Config files and TOML","text":"

    jj loads several types of config settings:

    • The built-in settings. These cannot be edited. They can be viewed in the cli/src/config/ directory in jj's source repo.

    • The user settings. These can be edited with jj config edit --user. User settings are located in the user config file, which can be found with jj config path --user.

    • The repo settings. These can be edited with jj config edit --repo and are located in .jj/repo/config.toml.

    • Settings specified in the command-line.

    These are listed in the order they are loaded; the settings from earlier items in the list are overridden by the settings from later items if they disagree. Every type of config except for the built-in settings is optional.

    See the TOML site and the syntax guide for a detailed description of the syntax. We cover some of the basics below.

    The first thing to remember is that the value of a setting (the part to the right of the = sign) should be surrounded in quotes if it's a string.

    "},{"location":"config/#dotted-style-and-headings","title":"Dotted style and headings","text":"

    In TOML, anything under a heading can be dotted instead. For example, user.name = \"YOUR NAME\" is equivalent to:

    [user]\nname = \"YOUR NAME\"\n

    For future reference, here are a couple of more complicated examples,

    # Dotted style\ntemplate-aliases.\"format_short_id(id)\" = \"id.shortest(12)\"\ncolors.\"commit_id prefix\".bold = true\n\n# is equivalent to:\n[template-aliases]\n\"format_short_id(id)\" = \"id.shortest(12)\"\n\n[colors]\n\"commit_id prefix\" = { bold = true }\n

    Jujutsu favors the dotted style in these instructions, if only because it's easier to write down in an unconfusing way. If you are confident with TOML then use whichever suits you in your config. If you mix dotted keys and headings, put the dotted keys before the first heading.

    That's probably enough TOML to keep you out of trouble but the syntax guide is very short if you ever need to check.

    "},{"location":"config/#user-settings","title":"User settings","text":"
    user.name = \"YOUR NAME\"\nuser.email = \"YOUR_EMAIL@example.com\"\n

    Don't forget to change these to your own details!

    "},{"location":"config/#ui-settings","title":"UI settings","text":""},{"location":"config/#colorizing-output","title":"Colorizing output","text":"

    Possible values are always, never and auto (default: auto). auto will use color only when writing to a terminal.

    This setting overrides the NO_COLOR environment variable (if set).

    ui.color = \"never\" # Turn off color\n
    "},{"location":"config/#custom-colors-and-styles","title":"Custom colors and styles","text":"

    You can customize the colors used for various elements of the UI. For example:

    colors.commit_id = \"green\"\n

    The following colors are available:

    • black
    • red
    • green
    • yellow
    • blue
    • magenta
    • cyan
    • white
    • default

    All of them but \"default\" come in a bright version too, e.g. \"bright red\". The \"default\" color can be used to override a color defined by a parent style (explained below).

    You can also use a 6-digit hex code for more control over the exact color used:

    colors.change_id = \"#ff1525\"\n

    If you use a string value for a color, as in the examples above, it will be used for the foreground color. You can also set the background color, or make the text bold or underlined. For that, you need to use a table:

    colors.commit_id = { fg = \"green\", bg = \"#ff1525\", bold = true, underline = true }\n

    The key names are called \"labels\". The above used commit_id as label. You can also create rules combining multiple labels. The rules work a bit like CSS selectors. For example, if you want to color commit IDs green in general but make the commit ID of the working-copy commit also be underlined, you can do this:

    colors.commit_id = \"green\"\ncolors.\"working_copy commit_id\" = { underline = true }\n

    Parts of the style that are not overridden - such as the foreground color in the example above - are inherited from the parent style.

    Which elements can be colored is not yet documented, but see the default color configuration for some examples of what's possible.

    "},{"location":"config/#default-command","title":"Default command","text":"

    When jj is run with no explicit subcommand, the value of the ui.default-command setting will be used instead. Possible values are any valid subcommand name, subcommand alias, or user-defined alias (defaults to \"log\").

    ui.default-command = \"log\"\n
    "},{"location":"config/#default-description","title":"Default description","text":"

    The value of the ui.default-description setting will be used to prepopulate the editor when describing changes with an empty description. This could be a useful reminder to fill in things like BUG=, TESTED= etc.

    ui.default-description = \"\\n\\nTESTED=TODO\"\n
    "},{"location":"config/#diff-format","title":"Diff format","text":"
    # Possible values: \"color-words\" (default), \"git\", \"summary\"\nui.diff.format = \"git\"\n
    "},{"location":"config/#generating-diffs-by-external-command","title":"Generating diffs by external command","text":"

    If ui.diff.tool is set, the specified diff command will be called instead of the internal diff function.

    [ui]\n# Use Difftastic by default\ndiff.tool = [\"difft\", \"--color=always\", \"$left\", \"$right\"]\n# Use tool named \"<name>\" (see below)\ndiff.tool = \"<name>\"\n

    The external diff tool can also be enabled by diff --tool <name> argument. For the tool named <name>, command arguments can be configured as follows.

    [merge-tools.<name>]\n# program = \"<name>\"  # Defaults to the name of the tool if not specified\ndiff-args = [\"--color=always\", \"$left\", \"$right\"]\n
    • $left and $right are replaced with the paths to the left and right directories to diff respectively.
    "},{"location":"config/#set-of-immutable-commits","title":"Set of immutable commits","text":"

    You can configure the set of immutable commits via revset-aliases.\"immutable_heads()\". The default set of immutable heads is trunk() | tags(). For example, to prevent rewriting commits on main@origin and commits authored by other users:

    # The `main.. &` bit is an optimization to scan for non-`mine()` commits only\n# among commits that are not in `main`.\nrevset-aliases.\"immutable_heads()\" = \"main@origin | (main@origin.. & ~mine())\"\n

    Ancestors of the configured set are also immutable. The root commit is always immutable even if the set is empty.

    "},{"location":"config/#default-revisions-to-log","title":"Default revisions to log","text":"

    You can configure the revisions jj log without -r should show.

    # Show commits that are not in `main@origin`\nrevsets.log = \"main@origin..\"\n
    "},{"location":"config/#graph-style","title":"Graph style","text":"
    # Possible values: \"curved\" (default), \"square\", \"ascii\", \"ascii-large\"\nui.graph.style = \"square\"\n
    "},{"location":"config/#node-style","title":"Node style","text":"

    The symbols used to represent commits or operations can be customized via templates.

    * templates.log_node for commits (with Option<Commit> keywords) * templates.op_log_node for operations (with Operation keywords)

    For example:

    [templates]\nlog_node = '''\ncoalesce(\n  if(!self, \"\ud83e\udf80\"),\n  if(current_working_copy, \"@\"),\n  if(root, \"\u2534\"),\n  if(immutable, \"\u25cf\", \"\u25cb\"),\n)\n'''\nop_log_node = 'if(current_operation, \"@\", \"\u25cb\")'\n

    "},{"location":"config/#wrap-log-content","title":"Wrap log content","text":"

    If enabled, log/obslog/op log content will be wrapped based on the terminal width.

    ui.log-word-wrap = true\n
    "},{"location":"config/#display-of-commit-and-change-ids","title":"Display of commit and change ids","text":"

    Can be customized by the format_short_id() template alias.

    [template-aliases]\n# Highlight unique prefix and show at least 12 characters (default)\n'format_short_id(id)' = 'id.shortest(12)'\n# Just the shortest possible unique prefix\n'format_short_id(id)' = 'id.shortest()'\n# Show unique prefix and the rest surrounded by brackets\n'format_short_id(id)' = 'id.shortest(12).prefix() ++ \"[\" ++ id.shortest(12).rest() ++ \"]\"'\n# Always show 12 characters\n'format_short_id(id)' = 'id.short(12)'\n

    To customize these separately, use the format_short_commit_id() and format_short_change_id() aliases:

    [template-aliases]\n# Uppercase change ids. `jj` treats change and commit ids as case-insensitive.\n'format_short_change_id(id)' = 'format_short_id(id).upper()'\n

    To get shorter prefixes for certain revisions, set revsets.short-prefixes:

    # Prioritize the current branch\nrevsets.short-prefixes = \"(main..@)::\"\n
    "},{"location":"config/#relative-timestamps","title":"Relative timestamps","text":"

    Can be customized by the format_timestamp() template alias.

    [template-aliases]\n# Full timestamp in ISO 8601 format\n'format_timestamp(timestamp)' = 'timestamp'\n# Relative timestamp rendered as \"x days/hours/seconds ago\"\n'format_timestamp(timestamp)' = 'timestamp.ago()'\n

    jj op log defaults to relative timestamps. To use absolute timestamps, you will need to modify the format_time_range() template alias.

    [template-aliases]\n'format_time_range(time_range)' = 'time_range.start() ++ \" - \" ++ time_range.end()'\n
    "},{"location":"config/#author-format","title":"Author format","text":"

    Can be customized by the format_short_signature() template alias.

    [template-aliases]\n# Full email address (default)\n'format_short_signature(signature)' = 'signature.email()'\n# Both name and email address\n'format_short_signature(signature)' = 'signature'\n# Username part of the email address\n'format_short_signature(signature)' = 'signature.username()'\n
    "},{"location":"config/#pager","title":"Pager","text":"

    The default pager is can be set via ui.pager or the PAGER environment variable. The priority is as follows (environment variables are marked with a $):

    ui.pager > $PAGER

    less -FRX is the default pager in the absence of any other setting, except on Windows where it is :builtin.

    The special value :builtin enables usage of the integrated pager. It is likely if you are using a standard Linux distro, your system has $PAGER set already and that will be preferred over the built-in. To use the built-in:

    jj config set --user ui.pager :builtin\n

    It is possible the default will change to :builtin for all platforms in the future.

    Additionally, paging behavior can be toggled via ui.paginate like so:

    # Enable pagination for commands that support it (default)\nui.paginate = \"auto\"\n# Disable all pagination, equivalent to using --no-pager\nui.paginate = \"never\"\n
    "},{"location":"config/#processing-contents-to-be-paged","title":"Processing contents to be paged","text":"

    If you'd like to pass the output through a formatter e.g. diff-so-fancy before piping it through a pager you must do it using a subshell as, unlike git or hg, the command will be executed directly. For example:

    ui.pager = [\"sh\", \"-c\", \"diff-so-fancy | less -RFX\"]\n
    "},{"location":"config/#aliases","title":"Aliases","text":"

    You can define aliases for commands, including their arguments. For example:

    # `jj l` shows commits on the working-copy commit's (anonymous) branch\n# compared to the `main` branch\naliases.l = [\"log\", \"-r\", \"(main..@):: | (main..@)-\"]\n
    "},{"location":"config/#editor","title":"Editor","text":"

    The default editor is set via ui.editor, though there are several places to set it. The priority is as follows (environment variables are marked with a $):

    $JJ_EDITOR > ui.editor > $VISUAL > $EDITOR

    Pico is the default editor (Notepad on Windows) in the absence of any other setting, but you could set it explicitly too.

    ui.editor = \"pico\"\n

    To use NeoVim instead:

    ui.editor = \"nvim\"\n

    For GUI editors you possibly need to use a -w or --wait. Some examples:

    ui.editor = \"code -w\"       # VS Code\nui.editor = \"bbedit -w\"     # BBEdit\nui.editor = \"subl -n -w\"    # Sublime Text\nui.editor = \"mate -w\"       # TextMate\nui.editor = [\"C:/Program Files/Notepad++/notepad++.exe\",\n    \"-multiInst\", \"-notabbar\", \"-nosession\", \"-noPlugin\"] # Notepad++\nui.editor = \"idea --temp-project --wait\"   #IntelliJ\n

    Obviously, you would only set one line, don't copy them all in!

    "},{"location":"config/#editing-diffs","title":"Editing diffs","text":"

    The ui.diff-editor setting affects the tool used for editing diffs (e.g. jj split, jj squash -i). The default is the special value :builtin, which launches a built-in TUI tool (known as scm-diff-editor) to edit the diff in your terminal.

    jj makes the following substitutions:

    • $left and $right are replaced with the paths to the left and right directories to diff respectively.

    If no arguments are specified, [\"$left\", \"$right\"] are set by default.

    For example:

    # Use merge-tools.kdiff3.edit-args\nui.diff-editor = \"kdiff3\"\n# Specify edit-args inline\nui.diff-editor = [\"kdiff3\", \"--merge\", \"$left\", \"$right\"]\n

    If ui.diff-editor consists of a single word, e.g. \"kdiff3\", the arguments will be read from the following config keys.

    # merge-tools.kdiff3.program = \"kdiff3\"      # Defaults to the name of the tool if not specified\nmerge-tools.kdiff3.edit-args = [\n    \"--merge\", \"--cs\", \"CreateBakFiles=0\", \"$left\", \"$right\"]\n
    "},{"location":"config/#experimental-3-pane-diff-editing","title":"Experimental 3-pane diff editing","text":"

    The special \"meld-3\" diff editor sets up Meld to show 3 panes: the sides of the diff on the left and right, and an editing pane in the middle. This allow you to see both sides of the original diff while editing. If you use ui.diff-editor = \"meld-3\", note that you can still get the 2-pane Meld view using jj diff --tool meld.

    To configure other diff editors, you can include $output together with $left and $right in merge-tools.TOOL.edit-args. jj will replace $output with the directory where the diff editor will be expected to put the result of the user's edits. Initially, the contents of $output will be the same as the contents of $right.

    "},{"location":"config/#jj-instructions","title":"JJ-INSTRUCTIONS","text":"

    When editing a diff, jj will include a synthetic file called JJ-INSTRUCTIONS in the diff with instructions on how to edit the diff. Any changes you make to this file will be ignored. To suppress the creation of this file, set ui.diff-instructions = false.

    "},{"location":"config/#using-vim-as-a-diff-editor","title":"Using Vim as a diff editor","text":"

    Using ui.diff-editor = \"vimdiff\" is possible but not recommended. For a better experience, you can follow instructions from the Wiki to configure the DirDiff Vim plugin and/or the vimtabdiff Python script.

    "},{"location":"config/#3-way-merge-tools-for-conflict-resolution","title":"3-way merge tools for conflict resolution","text":"

    The ui.merge-editor key specifies the tool used for three-way merge tools by jj resolve. For example:

    # Use merge-tools.meld.merge-args\nui.merge-editor = \"meld\"  # Or \"vscode\" or \"kdiff3\" or \"vimdiff\"\n# Specify merge-args inline\nui.merge-editor = [\"meld\", \"$left\", \"$base\", \"$right\", \"-o\", \"$output\"]\n

    The \"vscode\", \"meld\", \"kdiff3\", and \"vimdiff\" tools can be used out of the box, as long as they are installed.

    Using VS Code as a merge tool works well with VS Code's Remote Development functionality, as long as jj is called from VS Code's terminal.

    "},{"location":"config/#setting-up-a-custom-merge-tool","title":"Setting up a custom merge tool","text":"

    To use a different tool named TOOL, the arguments to pass to the tool MUST be specified either inline or in the merge-tools.TOOL.merge-args key. As an example of how to set this key and other tool configuration options, here is the out-of-the-box configuration of the three default tools. (There is no need to copy it to your config file verbatim, but you are welcome to customize it.)

    # merge-tools.kdiff3.program  = \"kdiff3\"     # Defaults to the name of the tool if not specified\nmerge-tools.kdiff3.merge-args = [\"$base\", \"$left\", \"$right\", \"-o\", \"$output\", \"--auto\"]\nmerge-tools.meld.merge-args = [\"$left\", \"$base\", \"$right\", \"-o\", \"$output\", \"--auto-merge\"]\n\nmerge-tools.vimdiff.merge-args = [\"-f\", \"-d\", \"$output\", \"-M\",\n    \"$left\", \"$base\", \"$right\",\n    \"-c\", \"wincmd J\", \"-c\", \"set modifiable\",\n    \"-c\", \"set write\"]\nmerge-tools.vimdiff.program = \"vim\"\nmerge-tools.vimdiff.merge-tool-edits-conflict-markers = true    # See below for an explanation\n

    jj makes the following substitutions:

    • $output (REQUIRED) is replaced with the name of the file that the merge tool should output. jj will read this file after the merge tool exits.

    • $left and $right are replaced with the paths to two files containing the content of each side of the conflict.

    • $base is replaced with the path to a file containing the contents of the conflicted file in the last common ancestor of the two sides of the conflict.

    "},{"location":"config/#editing-conflict-markers-with-a-tool-or-a-text-editor","title":"Editing conflict markers with a tool or a text editor","text":"

    By default, the merge tool starts with an empty output file. If the tool puts anything into the output file, and exits with the 0 exit code, jj assumes that the conflict is fully resolved. This is appropriate for most graphical merge tools.

    Some tools (e.g. vimdiff) can present a multi-way diff but don't resolve conflict themselves. When using such tools, jj can help you by populating the output file with conflict markers before starting the merge tool (instead of leaving the output file empty and letting the merge tool fill it in). To do that, set the merge-tools.vimdiff.merge-tool-edits-conflict-markers = true option.

    With this option set, if the output file still contains conflict markers after the conflict is done, jj assumes that the conflict was only partially resolved and parses the conflict markers to get the new state of the conflict. The conflict is considered fully resolved when there are no conflict markers left.

    "},{"location":"config/#commit-signing","title":"Commit Signing","text":"

    jj can be configured to sign and verify the commits it creates using either GnuPG or SSH signing keys.

    To do this you need to configure a signing backend.

    "},{"location":"config/#gnupg-signing","title":"GnuPG Signing","text":"
    [signing]\nsign-all = true\nbackend = \"gpg\"\nkey = \"4ED556E9729E000F\"\n## You can set `key` to anything accepted by `gpg -u`\n# key = \"signing@example.com\"\n

    By default the gpg backend will look for a gpg binary on your path. If you want to change the program used or specify a path to gpg explicitly you can set:

    signing.backends.gpg.program = \"gpg2\"\n

    Also by default the gpg backend will ignore key expiry when verifying commit signatures. To consider expired keys as invalid you can set:

    signing.backends.gpg.allow-expired-keys = false\n
    "},{"location":"config/#ssh-signing","title":"SSH Signing","text":"
    [signing]\nsign-all = true\nbackend = \"ssh\"\nkey = \"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGj+J6N6SO+4P8dOZqfR1oiay2yxhhHnagH52avUqw5h\"\n## You can also use a path instead of embedding the key\n# key = \"/home/me/.ssh/id_for_signing.pub\"\n

    By default the ssh backend will look for a ssh-keygen binary on your path. If you want to change the program used or specify a path to ssh-keygen explicitly you can set:

    signing.backends.ssh.program = \"/path/to/ssh-keygen\"\n

    When verifying commit signatures the ssh backend needs to be provided with an allowed-signers file containing the public keys of authors whose signatures you want to be able to verify.

    You can find the format for this file in the ssh-keygen man page. This can be provided as follows:

    signing.backends.ssh.allowed-signers = \"/path/to/allowed-signers\"\n
    "},{"location":"config/#git-settings","title":"Git settings","text":""},{"location":"config/#default-remotes-for-jj-git-fetch-and-jj-git-push","title":"Default remotes for jj git fetch and jj git push","text":"

    By default, if a single remote exists it is used for jj git fetch and jj git push; however if multiple remotes exist, the default remote is assumed to be named \"origin\", just like in Git. Sometimes this is undesirable, e.g. when you want to fetch from a different remote than you push to, such as a GitHub fork.

    To change this behavior, you can modify the repository configuration variable git.fetch, which can be a single remote, or a list of remotes to fetch from multiple places:

    jj config set --repo git.fetch \"upstream\"\njj config set --repo git.fetch '[\"origin\", \"upstream\"]'\n

    Similarly, you can also set the variable git.push to cause jj git push to push to a different remote:

    jj config set --repo git.push \"github\"\n

    Note that unlike git.fetch, git.push can currently only be a single remote. This is not a hard limitation, and could be changed in the future if there is demand.

    "},{"location":"config/#automatic-local-branch-creation","title":"Automatic local branch creation","text":"

    When jj imports a new remote-tracking branch from Git, it can also create a local branch with the same name. This feature is disabled by default because it may be undesirable in some repositories, e.g.:

    • There is a remote with a lot of historical branches that you don't want to be exported to the co-located Git repo.
    • There are multiple remotes with conflicting views of that branch, resulting in an unhelpful conflicted state.

    You can enable this behavior by setting git.auto-local-branch like so,

    git.auto-local-branch = true\n

    This setting is applied only to new remote branches. Existing remote branches can be tracked individually by using jj branch track/untrack commands.

    # import feature1 branch and start tracking it\njj branch track feature1@origin\n# delete local gh-pages branch and stop tracking it\njj branch delete gh-pages\njj branch untrack gh-pages@upstream\n
    "},{"location":"config/#abandon-commits-that-became-unreachable-in-git","title":"Abandon commits that became unreachable in Git","text":"

    By default, when jj imports refs from Git, it will look for commits that used to be reachable but no longer are reachable. Those commits will then be abandoned, and any descendant commits will be rebased off of them (as usual when commits are abandoned). You can disable this behavior and instead leave the Git-unreachable commits in your repo by setting:

    git.abandon-unreachable-commits = false\n
    "},{"location":"config/#prefix-for-generated-branches-on-push","title":"Prefix for generated branches on push","text":"

    jj git push --change generates branch names with a prefix of \"push-\" by default. You can pick a different prefix by setting git.push-branch-prefix. For example:

    git.push-branch-prefix = \"martinvonz/push-\"\n
    "},{"location":"config/#filesystem-monitor","title":"Filesystem monitor","text":"

    In large repositories, it may be beneficial to use a \"filesystem monitor\" to track changes to the working copy. This allows jj to take working copy snapshots without having to rescan the entire working copy.

    "},{"location":"config/#watchman","title":"Watchman","text":"

    To configure the Watchman filesystem monitor, set core.fsmonitor = \"watchman\". Ensure that you have installed the Watchman executable on your system.

    Debugging commands are available under jj debug watchman.

    "},{"location":"config/#ways-to-specify-jj-config-details","title":"Ways to specify jj config: details","text":""},{"location":"config/#user-config-file","title":"User config file","text":"

    An easy way to find the user config file is:

    jj config path --user\n

    The rest of this section covers the details of where this file can be located.

    On all platforms, the user's global jj configuration file is located at either ~/.jjconfig.toml (where ~ represents $HOME on Unix-likes, or %USERPROFILE% on Windows) or in a platform-specific directory. The platform-specific location is recommended for better integration with platform services. It is an error for both of these files to exist.

    Platform Value Example Linux $XDG_CONFIG_HOME/jj/config.toml /home/alice/.config/jj/config.toml macOS $HOME/Library/Application Support/jj/config.toml /Users/Alice/Library/Application Support/jj/config.toml Windows {FOLDERID_RoamingAppData}\\jj\\config.toml C:\\Users\\Alice\\AppData\\Roaming\\jj\\config.toml

    The location of the jj config file can also be overridden with the JJ_CONFIG environment variable. If it is not empty, it should contain the path to a TOML file that will be used instead of any configuration file in the default locations. For example,

    env JJ_CONFIG=/dev/null jj log       # Ignores any settings specified in the config file.\n
    "},{"location":"config/#specifying-config-on-the-command-line","title":"Specifying config on the command-line","text":"

    You can use one or more --config-toml options on the command line to specify additional configuration settings. This overrides settings defined in config files or environment variables. For example,

    jj --config-toml='ui.color=\"always\"' --config-toml='ui.diff-editor=\"kdiff3\"' split\n

    Config specified this way must be valid TOML. In particular, string values must be surrounded by quotes. To pass these quotes to jj, most shells require surrounding those quotes with single quotes as shown above.

    In sh-compatible shells, --config-toml can be used to merge entire TOML files with the config specified in .jjconfig.toml:

    jj --config-toml=\"$(cat extra-config.toml)\" log\n
    "},{"location":"conflicts/","title":"First-class conflicts","text":""},{"location":"conflicts/#introduction","title":"Introduction","text":"

    Like Pijul and Darcs but unlike most other VCSs, Jujutsu can record conflicted states in commits. For example, if you rebase a commit and it results in a conflict, the conflict will be recorded in the rebased commit and the rebase operation will succeed. You can then resolve the conflict whenever you want. Conflicted states can be further rebased, merged, or backed out. Note that what's stored in the commit is a logical representation of the conflict, not conflict markers; rebasing a conflict doesn't result in a nested conflict markers (see technical doc for how this works).

    "},{"location":"conflicts/#advantages","title":"Advantages","text":"

    The deeper understanding of conflicts has many advantages:

    • Removes the need for things like git rebase/merge/cherry-pick/etc --continue. Instead, you get a single workflow for resolving conflicts: check out the conflicted commit, resolve conflicts, and amend.
    • Enables the \"auto-rebase\" feature, where descendants of rewritten commits automatically get rewritten. This feature mostly replaces Mercurial's Changeset Evolution.
    • Lets us define the change in a merge commit as being compared to the merged parents. That way, we can rebase merge commits correctly (unlike both Git and Mercurial). That includes conflict resolutions done in the merge commit, addressing a common use case for git rerere. Since the changes in a merge commit are displayed and rebased as expected, evil merges are arguably not as evil anymore.
    • Allows you to postpone conflict resolution until you're ready for it. You can easily keep all your work-in-progress commits rebased onto upstream's head if you like.
    • Criss-cross merges and octopus merges become trivial (implementation-wise); some cases that Git can't currently handle, or that would result in nested conflict markers, can be automatically resolved.
    • Enables collaborative conflict resolution. (This assumes that you can share the conflicts with others, which you probably shouldn't do if some people interact with your project using Git.)

    For information about how conflicts are handled in the working copy, see here.

    "},{"location":"conflicts/#conflict-markers","title":"Conflict markers","text":"

    Conflicts are \"materialized\" using conflict markers in various contexts. For example, when you run jj edit on a commit with a conflict, it will be materialized in the working copy. Conflicts are also materialized when they are part of diff output (e.g. jj show on a commit that introduces or resolves a conflict). Here's an example of how Git can render a conflict using its \"diff3\" style:

      <<<<<<< left\n  apple\n  grapefruit\n  orange\n  ======= base\n  apple\n  grape\n  orange\n  ||||||| right\n  APPLE\n  GRAPE\n  ORANGE\n  >>>>>>>\n

    In this example, the left side changed \"grape\" to \"grapefruit\", and the right side made all lines uppercase. To resolve the conflict, we would presumably keep the right side (the third section) and replace \"GRAPE\" by \"GRAPEFRUIT\". This way of visually finding the changes between the base and one side and then applying them to the other side is a common way of resolving conflicts when using Git's \"diff3\" style.

    Jujutsu helps you by combining the base and one side into a unified diff for you, making it easier to spot the differences to apply to the other side. Here's how that would look for the same example as above:

      <<<<<<<\n  %%%%%%%\n   apple\n  -grape\n  +grapefruit\n   orange\n  +++++++\n  APPLE\n  GRAPE\n  ORANGE\n  >>>>>>>\n

    As in Git, the <<<<<<< and >>>>>>> lines mark the start and end of the conflict. The %%%%%%% line indicates the start of a diff. The +++++++ line indicates the start of a snapshot (not a diff).

    There is another reason for this format (in addition to helping you spot the differences): The format supports more complex conflicts involving more than 3 inputs. Such conflicts can arise when you merge more than 2 commits. They would typically be rendered as a single snapshot (as above) but with more than one unified diffs. The process for resolving them is similar: Manually apply each diff onto the snapshot.

    "},{"location":"contributing/","title":"How to Contribute","text":""},{"location":"contributing/#policies","title":"Policies","text":"

    We'd love to accept your patches and contributions to this project. There are just a few small guidelines you need to follow.

    "},{"location":"contributing/#contributor-license-agreement","title":"Contributor License Agreement","text":"

    Contributions to this project must be accompanied by a Contributor License Agreement. You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project. Head over to https://cla.developers.google.com/ to see your current agreements on file or to sign a new one.

    You generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again.

    "},{"location":"contributing/#code-reviews","title":"Code reviews","text":"

    All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult GitHub Help for more information on using pull requests.

    Unlike many GitHub projects (but like many VCS projects), we care more about the contents of commits than about the contents of PRs. We review each commit separately, and we don't squash-merge the PR (so please manually squash any fixup commits before sending for review).

    Each commit should ideally do one thing. For example, if you need to refactor a function in order to add a new feature cleanly, put the refactoring in one commit and the new feature in a different commit. If the refactoring itself consists of many parts, try to separate out those into separate commits. You can use jj split to do it if you didn't realize ahead of time how it should be split up. Include tests and documentation in the same commit as the code the test and document. The commit message should describe the changes in the commit; the PR description can even be empty, but feel free to include a personal message.

    When you address comments on a PR, don't make the changes in a commit on top (as is typical on GitHub). Instead, please make the changes in the appropriate commit. You can do that by checking out the commit (jj checkout/new <commit>) and then squash in the changes when you're done (jj squash). jj git push will automatically force-push the branch.

    When your first PR has been approved, we typically give you contributor access, so you can address any remaining minor comments and then merge the PR yourself when you're ready. If you realize that some comments require non-trivial changes, please ask your reviewer to take another look.

    To avoid conflicts of interest, please don't merge a PR that has only been approved by someone from the same organization. Similarly, as a reviewer, there is no need to approve your coworkers' PRs, since the author should await an approval from someone else anyway. It is of course still appreciated if you review and comment on their PRs. Also, if the PR seems completely unrelated to your company's interests, do feel free to approve it.

    "},{"location":"contributing/#community-guidelines","title":"Community Guidelines","text":"

    This project follows Google's Open Source Community Guidelines.

    "},{"location":"contributing/#contributing-to-the-documentation","title":"Contributing to the documentation","text":"

    We appreciate bug reports about any problems, however small, lurking in our documentation website or in the jj help <command> docs. If a part of the bug report template does not apply, you can just delete it.

    Before reporting a problem with the documentation website, we'd appreciate it if you could check that the problem still exists in the \"prerelease\" version of the documentation (as opposed to the docs for one of the released versions of jj). You can use the version switcher in the top-left of the website to do so.

    If you are willing to make a PR fixing a documentation problem, even better!

    The documentation website sources are Markdown files located in the docs/ directory. You do not need to know Rust to work with them. See below for instructions on how to preview the HTML docs as you edit the Markdown files. Doing so is optional, but recommended.

    The jj help docs are sourced from the \"docstring\" comments inside the Rust sources, currently from the cli/src/commands directory. Working on them requires setting up a Rust development environment, as described below, and may occasionally require adjusting a test.

    "},{"location":"contributing/#learning-rust","title":"Learning Rust","text":"

    In addition to the Rust Book and the other excellent resources at https://www.rust-lang.org/learn, we recommend the \"Comprehensive Rust\" mini-course for an overview, especially if you are familiar with C++.

    "},{"location":"contributing/#setting-up-a-development-environment","title":"Setting up a development environment","text":"

    To develop jj, the mandatory steps are simply to install Rust (the default installer options are fine), clone the repository, and use cargo build , cargo fmt, cargo clippy --workspace --all-targets, and cargo test --workspace. If you are preparing a PR, there are some additional recommended steps.

    You will probably also want to make the gh-pages branch immutable (and thereby hidden from the default jj log output) by running the following in your repo:

    jj config set --repo \"revset-aliases.immutable_heads()\" \"main@origin | gh-pages@origin\"\n
    "},{"location":"contributing/#summary","title":"Summary","text":"

    One-time setup:

    rustup toolchain add nightly  # wanted for 'rustfmt'\nrustup toolchain add 1.76     # also specified in Cargo.toml\ncargo install cargo-insta\ncargo install cargo-watch\ncargo install cargo-nextest\n

    During development (adapt according to your preference):

    cargo watch --ignore '.jj/**' -s \\\n  'cargo clippy --workspace --all-targets \\\n   && cargo +1.76 check --workspace --all-targets'\ncargo +nightly fmt # Occasionally\ncargo nextest run --workspace # Occasionally\ncargo insta test --workspace --test-runner nextest # Occasionally\n

    WARNING: Build artifacts from debug builds and especially from repeated invocations of cargo test can quickly take up 10s of GB of disk space. Cargo will happily use up your entire hard drive. If this happens, run cargo clean.

    "},{"location":"contributing/#explanation","title":"Explanation","text":"

    These are listed roughly in order of decreasing importance.

    1. Nearly any change to jj's CLI will require writing or updating snapshot tests that use the insta crate. To make this convenient, install the cargo-insta binary. Use cargo insta test --workspace to run tests, and cargo insta review --workspace to update the snapshot tests. The --workspace flag is needed to run the tests on all crates; by default, only the crate in the current directory is tested.

    2. GitHub CI checks require that the code is formatted with the nightly version of rustfmt. To do this on your computer, install the nightly toolchain and use cargo +nightly fmt.

    3. Your code will be rejected if it cannot be compiled with the minimal supported version of Rust (\"MSRV\"). Currently, jj follows a rather casual MSRV policy: \"The current rustc stable version, minus one.\" As of this writing, that version is 1.76.0.

    4. Your code needs to pass cargo clippy. You can also use cargo +nightly clippy if you wish to see more warnings.

    5. You may also want to install and use cargo-watch. In this case, you should exclude .jj. directory from the filesystem watcher, as it gets updated on every jj log.

    6. To run tests more quickly, use cargo nextest run --workspace. To use nextest with insta, use cargo insta test --workspace --test-runner nextest.

      On Linux, you may be able to speed up nextest even further by using the mold linker, as explained below.

    "},{"location":"contributing/#using-mold-for-faster-tests-on-linux","title":"Using mold for faster tests on Linux","text":"

    On a machine with a multi-core CPU, one way to speed up cargo nextest on Linux is to use the multi-threaded mold linker. This linker may help if, currently, your CPU is underused while Rust is linking test binaries. Before proceeding with mold, you can check whether this is an issue worth solving using a system monitoring tool such as htop.

    mold is packaged for many distributions. On Debian, for example, sudo apt install mold should just work.

    A simple way to use mold is via the -run option, e.g.:

    mold -run cargo insta test --workspace --test-runner nextest\n

    There will be no indication that a different linker is used, except for higher CPU usage while linking and, hopefully, faster completion. You can verify that mold was indeed used by running readelf -p .comment target/debug/jj.

    There are also ways of having Rust use mold by default, see the \"How to use\" instructions.

    On recent versions of MacOS, the default linker Rust uses is already multi-threaded. It should use all the CPU cores without any configuration.

    "},{"location":"contributing/#previewing-the-html-documentation","title":"Previewing the HTML documentation","text":"

    The documentation for jj is automatically published to the website at https://martinvonz.github.io/jj/.

    When editing documentation, we'd appreciate it if you checked that the result will look as expected when published to the website.

    "},{"location":"contributing/#setting-up-the-prerequisites","title":"Setting up the prerequisites","text":"

    To build the website, you must have Python and poetry installed. If your distribution packages poetry, something like apt install python3-poetry is likely the best way to install it. Otherwise, you can download Python from https://python.org or follow the Python installation instructions. Finally, follow the Poetry installation instructions.

    Once you have poetry installed, you should ask it to install the rest of the required tools into a virtual environment as follows:

    # --no-root avoids a harmless error message starting with Poetry 1.7\npoetry install --no-root\n

    You may get requests to \"unlock a keyring\", an error messages about failing to do so, or, in the case of Poetry 1.7, it may simply hang indefinitely. The workaround is to either to unlock the keyring or to run the following, and then to try poetry install --no-root again:

    # For sh-compatible shells or recent versions of `fish`\nexport PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring\n
    "},{"location":"contributing/#building-the-html-docs-locally-with-live-reload","title":"Building the HTML docs locally (with live reload)","text":"

    The HTML docs are built with MkDocs. After following the above steps, you should be able to view the docs by running

    # Note: this and all the commands below should be run from the root of\n# the `jj` source tree.\npoetry run -- mkdocs serve\n

    and opening http://127.0.0.1:8000 in your browser.

    As you edit the md files, the website should be rebuilt and reloaded in your browser automatically, unless build errors occur.

    You should occasionally check the terminal from which you ran mkdocs serve for any build errors or warnings. Warnings about \"GET /versions.json HTTP/1.1\" code 404 are expected and harmless.

    "},{"location":"contributing/#how-to-build-the-entire-website-not-usually-necessary","title":"How to build the entire website (not usually necessary)","text":"

    The full jj website includes the documentation for several jj versions (prerelease, latest release, and the older releases). The top-level URL https://martinvonz.github.io/jj redirects to https://martinvonz.github.io/jj/latest, which in turn redirects to the docs for the last stable version.

    The different versions of documentation are managed and deployed with mike, which can be run with poetry run -- mike.

    On a POSIX system or WSL, one way to build the entire website is as follows (on Windows, you'll need to understand and adapt the shell script):

    1. Check out jj as a co-located jj + git repository (jj clone --colocate), cloned from your fork of jj (e.g. jjfan.github.com/jj). You can also use a pure Git repo if you prefer.

    2. Make sure jjfan.github.com/jj includes the gh-pages branch of the jj repo and run git fetch origin gh-pages.

    3. Go to the GitHub repository settings, enable GitHub Pages, and configure them to use the gh-pages branch (this is usually the default).

    4. Run the same sh script that is used in GitHub CI (details below):

      .github/scripts/docs-build-deploy 'https://jjfan.github.io/jj/'\\\n    prerelease main --push\n

      This should build the version of the docs from the current commit, deploy it as a new commit to the gh-pages branch, and push the gh-pages branch to the origin.

    5. Now, you should be able to see the full website, including your latest changes to the prerelease version, at https://jjfan.github.io/jj/prerelease/.

    6. (Optional) The previous steps actually only rebuild https://jjfan.github.io/jj/prerelease/ and its alias https://jjfan.github.io/jj/main/. If you'd like to test out version switching back and forth, you can also rebuild the docs for the latest release as follows.

      jj new v1.33.1  # Let's say `jj 1.33.1` is the currently the latest release\n.github/scripts/docs-build-deploy 'https://jjfan.github.io/jj/'\\\n    v1.33.1 latest --push\n
    7. (Optional) When you are done, you may want to reset the gh-branches to the same spot as it is in the upstream. If you configured the upstream remote, this can be done with:

      # This will LOSE any changes you made to `gh-pages`\njj git fetch --remote upstream\njj branch set gh-pages -r gh-pages@upstream\njj git push --remote origin --branch gh-pages\n

      If you want to preserve some of the changes you made, you can do jj branch set my-changes -r gh-pages BEFORE running the above commands.

    "},{"location":"contributing/#explanation-of-the-docs-build-deploy-script","title":"Explanation of the docs-build-deploy script","text":"

    The script sets up the site_url mkdocs config to 'https://jjfan.github.io/jj/'. If this config does not match the URL where you loaded the website, some minor website features (like the version switching widget) will have reduced functionality.

    Then, the script passes the rest of its arguments to potery run -- mike deploy, which does the rest of the job. Run poetry run -- mike help deploy to find out what the arguments do.

    If you need to do something more complicated, you can use poetry run -- mike ... commands. You can also edit the gh-pages branch directly, but take care to avoid files that will be overwritten by future invocations of mike. Then, you can submit a PR based on the gh-pages branch of https://martinvonz.github.com/jj (instead of the usual main branch).

    "},{"location":"contributing/#modifying-protobuffers-this-is-not-common","title":"Modifying protobuffers (this is not common)","text":"

    Occasionally, you may need to change the .proto files that define jj's data storage format. In this case, you will need to add a few steps to the above workflow.

    • Install the protoc compiler. This usually means either apt-get install protobuf-compiler or downloading an official release. The prost library docs have additional advice.
    • Run cargo run -p gen-protos regularly (or after every edit to a .proto file). This is the same as running cargo run from lib/gen-protos. The gen-protos binary will use the prost-build library to compile the .proto files into .rs files.
    • If you are adding a new .proto file, you will need to edit the list of these files in lib/gen-protos/src/main.rs.

    The .rs files generated from .proto files are included in the repository, and there is a GitHub CI check that will complain if they do not match.

    "},{"location":"contributing/#profiling","title":"Profiling","text":"

    One easy-to-use sampling profiler is samply. For example:

    cargo install samply\nsamply record jj diff\n
    Then just open the link it prints.

    Another option is to use the instrumentation we've added manually (using tracing::instrument) in various places. For example:

    JJ_TRACE=/tmp/trace.json jj diff\n
    Then go to https://ui.perfetto.dev/ in Chrome and load /tmp/trace.json from there.

    "},{"location":"git-comparison/","title":"Comparison with Git","text":""},{"location":"git-comparison/#introduction","title":"Introduction","text":"

    This document attempts to describe how Jujutsu is different from Git. See the Git-compatibility doc for information about how the jj command interoperates with Git repos.

    "},{"location":"git-comparison/#overview","title":"Overview","text":"

    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 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 commit. Details.
    • There's no index (staging area). Because the working copy is automatically committed, an index-like concept doesn't make sense. The index is very similar to an intermediate commit between HEAD and the working copy, so workflows that depend on it can be modeled using proper commits instead. Jujutsu has excellent support for moving changes between commits. Details.
    • No need for branch names (but they are supported). Git lets you check out a commit without attaching a branch. It calls this state \"detached HEAD\". This is the normal state in Jujutsu (there's actually no way -- yet, at least -- to have an active branch). However, Jujutsu keeps track of all visible heads (leaves) of the commit graph, so the commits won't get lost or garbage-collected.
    • No current branch. Git lets you check out a branch, making it the 'current branch', and new commits will automatically update the branch. This is necessary in Git because Git might otherwise lose track of the new commits. Jujutsu does not have a 'current branch'; instead, you update branches manually. For example, if you check out a commit with a branch, new commits are created on top of the branch, then you issue a later command to update the branch.
    • Conflicts can be committed. No commands fail because of merge conflicts. The conflicts are instead recorded in commits and you can resolve them later. Details.
    • Descendant commits are automatically rebased. Whenever you rewrite a commit (e.g. by running jj rebase), all its descendants commits will automatically be rebased on top. Branches pointing to it will also get updated, and so will the working copy if it points to any of the rebased commits.
    • Branches are identified by their names (across remotes). For example, if you pull from a remote that has a main branch, you'll get a branch by that name in your local repo as well. If you then move it and push back to the remote, the main branch on the remote will be updated. Details.
    • The operation log replaces reflogs. The operation log is similar to reflogs, but is much more powerful. It keeps track of atomic updates to all refs at once (Jujutsu thus improves on Git's per-ref history much in the same way that Subversion improved on RCS's per-file history). The operation log powers e.g. the undo functionality. Details
    • There's a single, virtual root commit. Like Mercurial, Jujutsu has a virtual commit (with a hash consisting of only zeros) called the \"root commit\" (called the \"null revision\" in Mercurial). This commit is a common ancestor of all commits. That removes the awkward state Git calls the \"unborn branch\" state (which is the state a newly initialized Git repo is in), and related command-line flags (e.g. git rebase --root, git checkout --orphan).
    "},{"location":"git-comparison/#the-index","title":"The index","text":"

    Git's \"index\" has multiple roles. One role is as a cache of file system information. Jujutsu has something similar. Unfortunately, Git exposes the index to the user, which makes the CLI unnecessarily complicated (learning what the different flavors of git reset do, especially when combined with commits and/or paths, usually takes a while). Jujutsu, like Mercurial, doesn't make that mistake.

    As a Git power-user, you may think that you need the power of the index to commit only part of the working copy. However, Jujutsu provides commands for more directly achieving most use cases you're used to using Git's index for. For example, to create a commit from part of the changes in the working copy, you might be used to using git add -p; git commit. With Jujutsu, you'd instead use jj split to split the working-copy commit into two commits. To add more 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 <file> to move a specific file.

    "},{"location":"git-comparison/#command-equivalence-table","title":"Command equivalence table","text":"

    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/amend -r <revision> will move the diff from that revision into its parent.

    Use case Jujutsu command Git command Create a new repo jj git init [--colocate] git init Clone an existing repo jj git clone <source> <destination> (there is no support for cloning non-Git repos yet) git clone <source> <destination> Update the local repo with all branches from a remote jj git fetch [--remote <remote>] (there is no support for fetching into non-Git repos yet) git fetch [<remote>] Update a remote repo with all branches from the local repo jj git push --all [--remote <remote>] (there is no support for pushing from non-Git repos yet) git push --all [<remote>] Update a remote repo with a single branch from the local repo jj git push --branch <branch name> [--remote <remote>] (there is no support for pushing from non-Git repos yet) git push <remote> <branch name> Show summary of current work and repo status jj st git status Show diff of the current change jj diff git diff HEAD Show diff of another change jj diff -r <revision> git diff <revision>^ <revision> Show diff from another change to the current change jj diff --from <revision> git diff <revision> Show diff from change A to change B jj diff --from A --to B git diff A B Show description and diff of a change jj show <revision> git show <revision> Add a file to the current change touch filename touch filename; git add filename Remove a file from the current change rm filename git rm filename Modify a file in the current change echo stuff >> filename echo stuff >> filename Finish work on the current change and start a new change jj commit git commit -a See log of ancestors of the current commit jj log -r ::@ git log --oneline --graph --decorate See log of all reachable commits jj log -r 'all()' or jj log -r :: git log --oneline --graph --decorate --branches Show log of commits not on the main branch jj log (TODO) Search among files versioned in the repository grep foo $(jj files), or rg --no-require-git foo git grep foo Abandon the current change and start a new change jj abandon git reset --hard (cannot be undone) Make the current change empty jj restore git reset --hard (same as abandoning a change since Git has no concept of a \"change\") Abandon the parent of the working copy, but keep its diff in the working copy jj squash --from @- git reset --soft HEAD~ Discard working copy changes in some files jj restore <paths>... git restore <paths>... or git checkout HEAD -- <paths>... Edit description (commit message) of the current change jj describe Not supported Edit description (commit message) of the previous change jj describe @- git commit --amend (first make sure that nothing is staged) Temporarily put away the current change jj new @- (the old working-copy commit remains as a sibling commit) (the old working-copy commit X can be restored with jj edit X) git stash Start working on a new change based on the <main> branch jj new main git switch -c topic main or git checkout -b topic main (may need to stash or commit first) Move branch A onto branch B jj rebase -b A -d B git rebase B A (may need to rebase other descendant branches separately) Move change A and its descendants onto change B jj rebase -s A -d B git 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-D jj rebase -r C -d A; jj 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 change jj squash/amend git commit --amend -a Interactively move part of the diff in the current change into the parent change jj squash/amend -i git add -p; git commit --amend Move the diff in the working copy into an ancestor jj squash --into X git commit --fixup=X; git rebase -i --autosquash X^ Interactively move part of the diff in an arbitrary change to another arbitrary change jj squash -i --from X --into Y Not supported Interactively split the changes in the working copy in two jj split git commit -p Interactively split an arbitrary change in two jj split -r <revision> Not supported (can be emulated with the \"edit\" action in git rebase -i) Interactively edit the diff in a given change jj diffedit -r <revision> Not supported (can be emulated with the \"edit\" action in git rebase -i) Resolve conflicts and continue interrupted operation echo resolved > filename; jj squash/amend (operations don't get interrupted, so no need to continue) echo resolved > filename; git add filename; git rebase/merge/cherry-pick --continue Create a copy of a commit on top of another commit jj duplicate <source>; jj rebase -r <duplicate commit> -d <destination> (there's no single command for it yet) git co <destination>; git cherry-pick <source> Find the root of the working copy (or check if in a repo) jj workspace root git rev-parse --show-toplevel List branches jj branch list git branch Create a branch jj branch create <name> -r <revision> git branch <name> <revision> Move a branch forward jj branch set <name> -r <revision> git branch -f <name> <revision> Move a branch backward or sideways jj branch set <name> -r <revision> --allow-backwards git branch -f <name> <revision> Delete a branch jj branch delete <name> git branch --delete <name> See log of operations performed on the repo jj op log Not supported Undo an earlier operation jj [op] undo <operation ID> (jj undo is an alias for jj op undo) Not supported Create a commit that cancels out a previous commit jj backout -r <revision> git revert <revision>"},{"location":"git-compatibility/","title":"Git compatibility","text":"

    Jujutsu has two backends for storing commits. One of them uses a regular Git repo, which means that you can collaborate with Git users without them even knowing that you're not using the git CLI.

    See jj help git for help about the jj git family of commands, and e.g. jj help git push for help about a specific command (use jj git push -h for briefer help).

    "},{"location":"git-compatibility/#supported-features","title":"Supported features","text":"

    The following list describes which Git features Jujutsu is compatible with. For a comparison with Git, including how workflows are different, see the Git-comparison doc.

    • Configuration: Partial. The only configuration from Git (e.g. in ~/.gitconfig) that's respected is the following. Feel free to file a bug if you miss any particular configuration options.
      • The configuration of remotes ([remote \"<name>\"]).
      • core.excludesFile
    • Authentication: Partial. Only ssh-agent, a password-less key ( only ~/.ssh/id_rsa, ~/.ssh/id_ed25519 or ~/.ssh/id_ed25519_sk), or a credential.helper.
    • Branches: Yes. You can read more about how branches work in Jujutsu and how they interoperate with Git.
    • Tags: Partial. You can check out tagged commits by name (pointed to be either annotated or lightweight tags), but you cannot create new tags.
    • .gitignore: Yes. Ignores in .gitignore files are supported. So are ignores in .git/info/exclude or configured via Git's core.excludesfile config. The .gitignore support uses a native implementation, so please report a bug if you notice any difference compared to git.
    • .gitattributes: No. There's #53 about adding support for at least the eol attribute.
    • Hooks: No. There's #405 specifically for providing the checks from https://pre-commit.com.
    • Merge commits: Yes. Octopus merges (i.e. with more than 2 parents) are also supported.
    • Detached HEAD: Yes. Jujutsu supports anonymous branches, so this is a natural state.
    • Orphan branch: Yes. Jujutsu has a virtual root commit that appears as parent of all commits Git would call \"root commits\".
    • Staging area: Kind of. The staging area will be ignored. For example, jj diff will show a diff from the Git HEAD to the working copy. There are ways of fulfilling your use cases without a staging area.
    • Garbage collection: Yes. It should be safe to run git gc in the Git repo, but it's not tested, so it's probably a good idea to make a backup of the whole workspace first. There's no garbage collection and repacking of Jujutsu's own data structures yet, however.
    • Bare repositories: Yes. You can use jj git init --git-repo=<path> to create a repo backed by a bare Git repo.
    • Submodules: No. They will not show up in the working copy, but they will not be lost either.
    • Partial clones: No. We use the libgit2 library, which doesn't have support for partial clones.
    • Shallow clones: No. We use the libgit2 library, which doesn't have support for shallow clones.
    • git-worktree: No. However, there's native support for multiple working copies backed by a single repo. See the jj workspace family of commands.
    • Sparse checkouts: No. However, there's native support for sparse checkouts. See the jj sparse command.
    • Signed commits: No. (#58)
    • Git LFS: No. (#80)
    "},{"location":"git-compatibility/#creating-an-empty-repo","title":"Creating an empty repo","text":"

    To create an empty repo using the Git backend, use jj init --git <name>. Since the command creates a Jujutsu repo, it will have a .jj/ directory. The underlying Git repo will be inside of that directory (currently in .jj/repo/store/git/).

    "},{"location":"git-compatibility/#creating-a-repo-backed-by-an-existing-git-repo","title":"Creating a repo backed by an existing Git repo","text":"

    To create a Jujutsu repo backed by a Git repo you already have on disk, use jj git init --git-repo=<path to Git repo> <name>. The repo will work similar to a Git worktree, meaning that the working copies files and the record of the working-copy commit will be separate, but the commits will be accessible in both repos. Use jj git import to update the Jujutsu repo with changes made in the Git repo. Use jj git export to update the Git repo with changes made in the Jujutsu repo.

    "},{"location":"git-compatibility/#creating-a-repo-by-cloning-a-git-repo","title":"Creating a repo by cloning a Git repo","text":"

    To create a Jujutsu repo from a remote Git URL, use jj git clone <URL> [<destination>]. For example, jj git clone https://github.com/octocat/Hello-World will clone GitHub's \"Hello-World\" repo into a directory by the same name.

    "},{"location":"git-compatibility/#co-located-jujutsugit-repos","title":"Co-located Jujutsu/Git repos","text":"

    A \"co-located\" Jujutsu repo is a hybrid Jujutsu/Git repo. These can be created if you initialize the Jujutsu repo in an existing Git repo by running jj git init --colocate or with jj git clone --colocate. The Git repo and the Jujutsu repo then share the same working copy. Jujutsu will import and export from and to the Git repo on every jj command automatically.

    This mode is very convenient when tools (e.g. build tools) expect a Git repo to be present.

    It is allowed to mix jj and git commands in such a repo in any order. However, it may be easier to keep track of what is going on if you mostly use read-only git commands and use jj to make changes to the repo. One reason for this (see below for more) is that jj commands will usually put the git repo in a \"detached HEAD\" state, since in jj there is not concept of a \"currently tracked branch\". Before doing mutating Git commands, you may need to tell Git what the current branch should be with a git switch command.

    You can undo the results of mutating git commands using jj undo and jj op restore. Inside jj op log, changes by git will be represented as an \"import git refs\" operation.

    There are a few downsides to this mode of operation. Generally, using co-located repos may require you to deal with more involved Jujutsu and Git concepts.

    • Interleaving jj and git commands increases the chance of confusing branch conflicts or conflicted (AKA divergent) change ids. These never lose data, but can be annoying.

      Such interleaving can happen unknowingly. For example, some IDEs can cause it because they automatically run git fetch in the background from time to time.

    • In co-located repos with a very large number of branches or other refs, jj commands can get noticeably slower because of the automatic jj git import executed on each command. This can be mitigated by occasionally running jj util gc to speed up the import (that command includes packing the Git refs).

    • Git tools will have trouble with revisions that contain conflicted files. While jj renders these files with conflict markers in the working copy, they are stored in a non-human-readable fashion inside the repo. Git tools will often see this non-human-readable representation.

    • When a jj branch is conflicted, the position of the branch in the Git repo will disagree with one or more of the conflicted positions. The state of that branch in git will be labeled as though it belongs to a remote named \"git\", e.g. branch@git.

    • Jujutsu will ignore Git's staging area. It will not understand merge conflicts as Git represents them, unfinished git rebase states, as well as other less common states a Git repository can be in.

    • Colocated repositories are less resilient to concurrency issues if you share the repo using an NFS filesystem or Dropbox. In general, such use of Jujutsu is not currently thoroughly tested.

    • There may still be bugs when interleaving mutating jj and git commands, usually having to do with a branch pointer ending up in the wrong place. We are working on the known ones, and are not aware of any major ones. Please report any new ones you find, or if any of the known bugs are less minor than they appear.

    "},{"location":"git-compatibility/#converting-a-repo-into-a-co-located-repo","title":"Converting a repo into a co-located repo","text":"

    A Jujutsu repo backed by a Git repo has a full Git repo inside, so it is technically possible (though not officially supported) to convert it into a co-located repo like so:

    # Move the Git repo\nmv .jj/repo/store/git .git\n# Tell jj where to find it\necho -n '../../../.git' > .jj/repo/store/git_target\n# Ignore the .jj directory in Git\necho '/*' > .jj/.gitignore\n# Make the Git repository non-bare and set HEAD\ngit config --unset core.bare\njj st\n

    We may officially support this in the future. If you try this, we would appreciate feedback and bug reports.

    "},{"location":"git-compatibility/#branches","title":"Branches","text":"

    TODO: Describe how branches are mapped

    "},{"location":"git-compatibility/#format-mapping-details","title":"Format mapping details","text":"

    Paths are assumed to be UTF-8. I have no current plans to support paths with other encodings.

    Commits created by jj have a ref starting with refs/jj/ to prevent GC.

    Commit metadata that cannot be represented in Git commits (such as the Change ID and information about conflicts) is stored outside of the Git repo (currently in .jj/store/extra/).

    Commits with conflicts cannot be represented in Git. They appear in the Git commit as as root directories called.jjconflict-base-*/ and .jjconflict-side-*/. Note that the purpose of this representation is only to prevent GC of the relevant trees; the authoritative information is in the Git-external storage mentioned in the paragraph above. As long as you use jj commands to work with them, you won't notice those paths. If, on the other hand, you use e.g. git switch to check one of them out, you will see those directories in your working copy. If you then run e.g. jj status, the resulting snapshot will contain those directories, making it look like they replaced all the other paths in your repo. You will probably want to run jj abandon to get back to the state with the unresolved conflicts.

    "},{"location":"github/","title":"Using Jujutsu with GitHub and GitLab Projects","text":"

    This guide assumes a basic understanding of either Git or Mercurial.

    "},{"location":"github/#set-up-an-ssh-key","title":"Set up an SSH key","text":"

    As of October 2023 it's recommended to set up an SSH key to work with GitHub projects. See GitHub's Tutorial. This restriction may be lifted in the future, see issue #469 for more information and progress on authenticated HTTP.

    "},{"location":"github/#basic-workflow","title":"Basic workflow","text":"

    The simplest way to start with Jujutsu is to create a stack of commits first. You will only need to create a branch when you need to push the stack to a remote. There are two primary workflows: using a generated branch name or naming a branch.

    "},{"location":"github/#using-a-generated-branch-name","title":"Using a generated branch name","text":"

    In this example we're letting Jujutsu auto-create a branch.

    # Start a new commit off of the default branch.\n$ jj new main\n# Refactor some files, then add a description and start a new commit\n$ jj commit -m 'refactor(foo): restructure foo()'\n# Add a feature, then add a description and start a new commit\n$ jj commit -m 'feat(bar): add support for bar'\n# Let Jujutsu generate a branch name and push that to GitHub. Note that we\n# push the working-copy commit's *parent* because the working-copy commit\n# itself is empty.\n$ jj git push -c @-\n
    "},{"location":"github/#using-a-named-branch","title":"Using a named branch","text":"

    In this example, we create a branch named bar and then push it to the remote.

    # Start a new commit off of the default branch.\n$ jj new main\n# Refactor some files, then add a description and start a new commit\n$ jj commit -m 'refactor(foo): restructure foo()'\n# Add a feature, then add a description and start a new commit\n$ jj commit -m 'feat(bar): add support for bar'\n# Create a branch so we can push it to GitHub. Note that we created the branch\n# on the working-copy commit's *parent* because the working copy itself is empty.\n$ jj branch create bar -r @- # `bar` now contains the previous two commits.\n# Push the branch to GitHub (pushes only `bar`)\n$ jj git push\n

    While it's possible to create a branch in advance and commit on top of it in a Git-like manner, you will then need to move the branch manually when you create a new commits. Unlike Git, Jujutsu will not do it automatically.

    "},{"location":"github/#updating-the-repository","title":"Updating the repository","text":"

    As of October 2023, Jujutsu has no equivalent to a git pull command (see issue #1039). Until such a command is added, you need to use jj git fetch followed by a jj rebase -d $main_branch to update your changes.

    "},{"location":"github/#working-in-a-git-co-located-repository","title":"Working in a Git co-located repository","text":"

    After doing jj git init --colocate, Git will be in a detached HEAD state, which is unusual, as Git mainly works with branches. In a co-located repository, every jj command will automatically synchronize Jujutsu's view of the repo with Git's view. For example, jj commit updates the HEAD of the Git repository, enabling an incremental migration.

    $ nvim docs/tutorial.md\n$ # Do some more work.\n$ jj commit -m \"Update tutorial\"\n# Create a branch on the working-copy commit's parent\n$ jj branch create doc-update -r @-\n$ jj git push\n
    "},{"location":"github/#working-in-a-jujutsu-repository","title":"Working in a Jujutsu repository","text":"

    In a Jujutsu repository, the workflow is simplified. If there's no need for explicitly named branches, you can just generate one for a change. As Jujutsu is able to create a branch for a revision.

    $ # Do your work\n$ jj commit\n$ # Push change \"mw\", letting Jujutsu automatically create a branch called\n$ # \"push-mwmpwkwknuz\"\n$ jj git push --change mw\n
    "},{"location":"github/#addressing-review-comments","title":"Addressing review comments","text":"

    There are two workflows for addressing review comments, depending on your project's preference. Many projects prefer that you address comments by adding commits to your branch1. Some projects (such as Jujutsu and LLVM) instead prefer that you keep your commits clean by rewriting them and then force-pushing2.

    "},{"location":"github/#adding-new-commits","title":"Adding new commits","text":"

    If your project prefers that you address review comments by adding commits on top, you can do that by doing something like this:

    $ # Create a new commit on top of the `your-feature` branch from above.\n$ jj new your-feature\n$ # Address the comments by updating the code. Then review the changes.\n$ jj diff\n$ # Give the fix a description and create a new working-copy on top.\n$ jj commit -m 'address pr comments'\n$ # Update the branch to point to the new commit.\n$ jj branch set your-feature -r @-\n$ # Push it to your remote\n$ jj git push\n

    Notably, the above workflow creates a new commit for you. The same can be achieved without creating a new commit.

    Warning We strongly suggest to jj new after the example below, as all further edits still get amended to the previous commit.

    $ # Create a new commit on top of the `your-feature` branch from above.\n$ jj new your-feature\n$ # Address the comments by updating the code. Then review the changes.\n$ jj diff\n$ # Give the fix a description.\n$ jj describe -m 'address pr comments'\n$ # Update the branch to point to the current commit.\n$ jj branch set your-feature -r @\n$ # Push it to your remote\n$ jj git push\n
    "},{"location":"github/#rewriting-commits","title":"Rewriting commits","text":"

    If your project prefers that you keep commits clean, you can do that by doing something like this:

    $ # Create a new commit on top of the second-to-last commit in `your-feature`,\n$ # as reviewers requested a fix there.\n$ jj new your-feature- # NOTE: the trailing hyphen is not a typo!\n$ # Address the comments by updating the code. Then review the changes.\n$ jj diff\n$ # Squash the changes into the parent commit\n$ jj squash\n$ # Push the updated branch to the remote. Jujutsu automatically makes it a\n$ # force push\n$ jj git push --branch your-feature\n

    The hyphen after your-feature comes from the revset syntax.

    "},{"location":"github/#working-with-other-peoples-branches","title":"Working with other people's branches","text":"

    By default, jj git clone imports the default remote branch (which is usually main or master), but jj git fetch doesn't import new remote branches to local branches. This means that if you want to iterate or test another contributor's branch, you'll need to do jj new <branch>@<remote> onto it.

    If you want to import all remote branches including inactive ones, set git.auto-local-branch = true in the config file. Then you can specify a contributor's branch as jj new <branch> instead of jj new <branch>@<remote>.

    You can find more information on that setting here.

    "},{"location":"github/#using-github-cli","title":"Using GitHub CLI","text":"

    GitHub CLI will have trouble finding the proper Git repository path in jj repos that aren't co-located (see issue #1008). You can configure the $GIT_DIR environment variable to point it to the right path:

    $ GIT_DIR=.jj/repo/store/git gh issue list\n

    You can make that automatic by installing direnv and defining hooks in a .envrc file in the repository root to configure $GIT_DIR. Just add this line into .envrc:

    export GIT_DIR=$PWD/.jj/repo/store/git\n

    and run direnv allow to approve it for direnv to run. Then GitHub CLI will work automatically even in repos that aren't co-located so you can execute commands like gh issue list normally.

    "},{"location":"github/#useful-revsets","title":"Useful Revsets","text":"

    Log all revisions across all local branches that aren't on the main branch nor on any remote:

    $ jj log -r 'branches() & ~(main | remote_branches())'\n

    Log all revisions that you authored, across all branches that aren't on any remote:

    $ jj log -r 'mine() & branches() & ~remote_branches()'\n

    Log all remote branches that you authored or committed to:

    $ jj log -r 'remote_branches() & (mine() | committer(your@email.com))'\n

    Log all descendants of the current working copy that aren't on any remote:

    $ jj log -r '::@ & ~remote_branches()'\n
    "},{"location":"github/#merge-conflicts","title":"Merge conflicts","text":"

    For a detailed overview, how Jujutsu handles conflicts, revisit the tutorial.

    "},{"location":"github/#using-several-remotes","title":"Using several remotes","text":"

    It is common to use several remotes when contributing to a shared repository. For example, \"upstream\" can designate the remote where the changes will be merged through a pull-request while \"origin\" is your private fork of the project. In this case, you might want to jj git fetch from \"upstream\" and to jj git push to \"origin\".

    You can configure the default remotes to fetch from and push to in your configuration file (for example .jj/repo/config.toml):

    [git]\nfetch = \"upstream\"\npush = \"origin\"\n

    The default for both git.fetch and git.push is \"origin\".

    1. This is a GitHub-style review, as GitHub currently only is able to compare branches.\u00a0\u21a9

    2. If you're wondering why we prefer clean commits in this project, see e.g. this blog post \u21a9

    "},{"location":"glossary/","title":"Glossary","text":""},{"location":"glossary/#anonymous-branch","title":"Anonymous branch","text":"

    An anonymous branch is a chain of commits that doesn't have any named branches pointing to it or to any of its descendants. Unlike Git, Jujutsu keeps commits on anonymous branches around until they are explicitly abandoned. Visible anonymous branches are tracked by the view, which stores a list of heads of such branches.

    "},{"location":"glossary/#backend","title":"Backend","text":"

    A backend is an implementation of the storage layer. There are currently two builtin commit backends: the Git backend and the native backend. The Git backend stores commits in a Git repository. The native backend is used for testing purposes only. Alternative backends could be used, for example, if somebody wanted to use jj with a humongous monorepo (as Google does).

    There are also pluggable backends for storing other information than commits, such as the \"operation store backend\" for storing the operation log.

    "},{"location":"glossary/#branch","title":"Branch","text":"

    A branch is a named pointer to a commit. They automatically follow the commit if it gets rewritten. Branches are sometimes called \"named branches\" to distinguish them from anonymous branches, but note that they are more similar to Git's branches than to Mercurial's named branches. See here for details.

    "},{"location":"glossary/#change","title":"Change","text":"

    A change is a commit as it evolves over time.

    "},{"location":"glossary/#change-id","title":"Change ID","text":"

    A change ID is a unique identifier for a change. They are typically 16 bytes long and are often randomly generated. By default, jj log presents them as a sequence of 12 letters in the k-z range, at the beginning of a line. These are actually hexadecimal numbers that use \"digits\" z-k instead of 0-9a-f.

    For the git backend, Change IDs are currently maintained only locally and not exchanged via push/fetch operations.

    "},{"location":"glossary/#commit","title":"Commit","text":"

    A snapshot of the files in the repository at a given point in time (technically a tree object), together with some metadata. The metadata includes the author, the date, and pointers to the commit's parents. Through the pointers to the parents, the commits form a Directed Acyclic Graph (DAG) .

    Note that even though commits are stored as snapshots, they are often treated as differences between snapshots, namely compared to their parent's snapshot. If they have more than one parent, then the difference is computed against the result of merging the parents. For example, jj diff will show the differences introduced by a commit compared to its parent(s), and jj rebase will apply those changes onto another base commit.

    The word \"revision\" is used as a synonym for \"commit\".

    "},{"location":"glossary/#commit-id","title":"Commit ID","text":"

    A commit ID is a unique identifier for a commit. They are 20 bytes long when using the Git backend. They are presented in regular hexadecimal format at the end of the line in jj log, using 12 hexadecimal digits by default. When using the Git backend, the commit ID is the Git commit ID.

    "},{"location":"glossary/#co-located-repos","title":"Co-located repos","text":"

    When using the Git backend and the backing Git repository's .git/ directory is a sibling of .jj/, we call the repository \"co-located\". Most tools designed for Git can be easily used on such repositories. jj and git commands can be used interchangeably.

    See here for details.

    "},{"location":"glossary/#conflict","title":"Conflict","text":"

    Conflicts can occur in many places. The most common type is conflicts in files. Those are the conflicts that users coming from other VCSs are usually familiar with. You can see them in jj status and in jj log (the red \"conflict\" label at the end of the line). See here for details.

    Conflicts can also occur in branches. For example, if you moved a branch locally, and it was also moved on the remote, then the branch will be in a conflicted state after you pull from the remote. See here for details.

    Similar to a branch conflict, when a change is rewritten locally and remotely, for example, then the change will be in a conflicted state. We call that a divergent change.

    "},{"location":"glossary/#divergent-change","title":"Divergent change","text":"

    A divergent change is a change that has more than one visible commit.

    "},{"location":"glossary/#head","title":"Head","text":"

    A head is a commit with no descendants. The context in which it has no descendants varies. For example, the heads(X) revset function returns commits that have no descendants within the set X itself. The view records which anonymous heads (heads without a branch pointing to them) are visible at a given operation. Note that this is quite different from Git's HEAD.

    "},{"location":"glossary/#hidden-commits-abandoned-commits","title":"Hidden commits, abandoned commits","text":"

    See visible commits.

    "},{"location":"glossary/#operation","title":"Operation","text":"

    A snapshot of the visible commits and branches at a given point in time (technically a view object), together with some metadata. The metadata includes the username, hostname, timestamps, and pointers to the operation's parents.

    "},{"location":"glossary/#operation-log","title":"Operation log","text":"

    The operation log is the DAG formed by operation objects, much in the same way that commits form a DAG, which is sometimes called the \"commit history\". When operations happen in sequence, they form a single line in the graph. Operations that happen concurrently from jj's perspective result in forks and merges in the DAG.

    "},{"location":"glossary/#repository","title":"Repository","text":"

    Basically everything under .jj/, i.e. the full set of operations and commits.

    "},{"location":"glossary/#remote","title":"Remote","text":"

    TODO

    "},{"location":"glossary/#revision","title":"Revision","text":"

    A synonym for Commit.

    "},{"location":"glossary/#revset","title":"Revset","text":"

    Jujutsu supports a functional language for selecting a set of revisions. Expressions in this language are called \"revsets\". See here for details. We also often use the term \"revset\" for the set of revisions selected by a revset.

    "},{"location":"glossary/#rewrite","title":"Rewrite","text":"

    To \"rewrite\" a commit means to create a new version of that commit with different contents, metadata (including parent pointers), or both. Rewriting a commit results in a new commit, and thus a new commit ID, but the change ID generally remains the same. Some examples of rewriting a commit would be changing its description or rebasing it. Modifying the working copy rewrites the working copy commit.

    "},{"location":"glossary/#root-commit","title":"Root commit","text":"

    The root commit is a virtual commit at the root of every repository. It has a commit ID consisting of all '0's (00000000...) and a change ID consisting of all 'z's (zzzzzzzz...). It can be referred to in revsets by the function root(). Note that our definition of \"root commit\" is different from Git's; Git's \"root commits\" are the first commit(s) in the repository, i.e. the commits jj log -r root()+ will show.

    "},{"location":"glossary/#tree","title":"Tree","text":"

    A tree object represents a snapshot of a directory in the repository. Tree objects are defined recursively; each tree object only has the files and directories contained directly in the directory it represents.

    "},{"location":"glossary/#tracked-branches-and-tracking-branches","title":"Tracked branches and tracking branches","text":"

    A remote branch can be made \"tracked\" with the jj branch track command. This results in a \"tracking\" local branch that tracks the remote branch.

    See the branches documentation for a more detailed definition of these terms.

    "},{"location":"glossary/#visible-commits","title":"Visible commits","text":"

    Visible commits are the commits you see in jj log -r 'all()'. They are the commits that are reachable from an anonymous head in the view. Ancestors of a visible commit are implicitly visible.

    Intuitively, visible commits are the \"latest versions\" of a revision with a given change id. A commit that's abandoned or rewritten stops being visible and is labeled as \"hidden\". Such commits are no longer accessible using a change id, but they are still accessible by their commit id.

    "},{"location":"glossary/#view","title":"View","text":"

    A view is a snapshot of branches and their targets, anonymous heads, and working-copy commits. The anonymous heads define which commits are visible.

    A view object is similar to a tree object in that it represents a snapshot without history, and an operation object is similar to a commit object in that it adds metadata and history.

    "},{"location":"glossary/#workspace","title":"Workspace","text":"

    A workspace is a working copy and an associated repository. There can be multiple workspaces for a single repository. Each workspace has a .jj/ directory, but the commits and operations will be stored in the initial workspace; the other workspaces will have pointers to the initial workspace. See here for details.

    This is what Git calls a \"worktree\".

    "},{"location":"glossary/#working-copy","title":"Working copy","text":"

    The working copy contains the files you're currently working on. It is automatically snapshot at the beginning of almost every jj command, thus creating a new working-copy commit if any changes had been made in the working copy. Conversely, the working copy is automatically updated to the state of the working-copy commit at the end of almost every jj command. See here for details.

    This is what Git calls a \"working tree\".

    "},{"location":"glossary/#working-copy-commit","title":"Working-copy commit","text":"

    A commit that corresponds to the current state of the working copy. There is one working-copy commit per workspace. The current working-copy commits are tracked in the operation log.

    "},{"location":"install-and-setup/","title":"Installation and setup","text":""},{"location":"install-and-setup/#installation","title":"Installation","text":""},{"location":"install-and-setup/#download-pre-built-binaries-for-a-release","title":"Download pre-built binaries for a release","text":"

    There are pre-built binaries of the last released version of jj for Windows, Mac, or Linux (the \"musl\" version should work on all distributions).

    If you'd like to install a prerelease version, you'll need to use one of the options below.

    "},{"location":"install-and-setup/#cargo-binstall","title":"Cargo Binstall","text":"

    If you use cargo-binstall, you can install the same binaries of the last jj release from GitHub as follows:

    # Will put the jj binary for the latest release in ~/.cargo/bin by default\ncargo binstall --strategies crate-meta-data jj-cli\n

    Without the --strategies option, you may get equivalent binaries that should be compiled from the same source code.

    "},{"location":"install-and-setup/#linux","title":"Linux","text":""},{"location":"install-and-setup/#arch-linux","title":"Arch Linux","text":"

    You can install the jujutsu package from the official extra repository:

    pacman -S jujutsu\n

    Or install from the AUR repository with an AUR Helper:

    yay -S jujutsu-git\n
    "},{"location":"install-and-setup/#from-source","title":"From Source","text":"

    First make sure that you have the libssl-dev, openssl, pkg-config, and build-essential packages installed by running something like this:

    sudo apt-get install libssl-dev openssl pkg-config build-essential\n

    Now run either:

    # To install the *prerelease* version from the main branch\ncargo install --git https://github.com/martinvonz/jj.git --locked --bin jj jj-cli\n

    or:

    # To install the latest release\ncargo install --locked --bin jj jj-cli\n
    "},{"location":"install-and-setup/#nix-os","title":"Nix OS","text":"

    If you're on Nix OS you can install a released version of jj using the nixpkgs jujutsu package.

    To install a prerelease version, you can use the flake for this repository. For example, if you want to run jj loaded from the flake, use:

    nix run 'github:martinvonz/jj'\n

    You can also add this flake url to your system input flakes. Or you can install the flake to your user profile:

    # Installs the prerelease version from the main branch\nnix profile install 'github:martinvonz/jj'\n
    "},{"location":"install-and-setup/#homebrew","title":"Homebrew","text":"

    If you use linuxbrew, you can run:

    # Installs the latest release\nbrew install jj\n
    "},{"location":"install-and-setup/#mac","title":"Mac","text":""},{"location":"install-and-setup/#from-source_1","title":"From Source","text":"

    You may need to run some or all of these:

    xcode-select --install\nbrew install openssl\nbrew install pkg-config\nexport PKG_CONFIG_PATH=\"$(brew --prefix)/opt/openssl@3/lib/pkgconfig\"\n

    Now run either:

    # To install the *prerelease* version from the main branch\ncargo install --git https://github.com/martinvonz/jj.git --locked --bin jj jj-cli\n

    or:

    # To install the latest release\ncargo install --locked --bin jj jj-cli\n
    "},{"location":"install-and-setup/#homebrew_1","title":"Homebrew","text":"

    If you use Homebrew, you can run:

    # Installs the latest release\nbrew install jj\n
    "},{"location":"install-and-setup/#macports","title":"MacPorts","text":"

    You can also install jj via the MacPorts jujutsu port:

    # Installs the latest release\nsudo port install jujutsu\n
    "},{"location":"install-and-setup/#windows","title":"Windows","text":"

    Run either:

    # To install the *prerelease* version from the main branch\ncargo install --git https://github.com/martinvonz/jj.git --locked --bin jj jj-cli --features vendored-openssl\n

    or:

    # To install the latest release\ncargo install --locked --bin jj jj-cli --features vendored-openssl\n
    "},{"location":"install-and-setup/#initial-configuration","title":"Initial configuration","text":"

    You may want to configure your name and email so commits are made in your name.

    $ jj config set --user user.name \"Martin von Zweigbergk\"\n$ jj config set --user user.email \"martinvonz@google.com\"\n
    "},{"location":"install-and-setup/#command-line-completion","title":"Command-line completion","text":"

    To set up command-line completion, source the output of jj util completion bash/zsh/fish. Exactly how to source it depends on your shell.

    "},{"location":"install-and-setup/#bash","title":"Bash","text":"
    source <(jj util completion)  # --bash is the default\n
    "},{"location":"install-and-setup/#zsh","title":"Zsh","text":"
    autoload -U compinit\ncompinit\nsource <(jj util completion zsh)\n
    "},{"location":"install-and-setup/#fish","title":"Fish","text":"
    jj util completion fish | source\n
    "},{"location":"install-and-setup/#nushell","title":"Nushell","text":"
    jj util completion nushell | save completions-jj.nu\nuse completions-jj.nu *  # Or `source completions-jj.nu`\n
    "},{"location":"install-and-setup/#xonsh","title":"Xonsh","text":"
    source-bash $(jj util completion)\n
    "},{"location":"operation-log/","title":"Operation log","text":""},{"location":"operation-log/#introduction","title":"Introduction","text":"

    Jujutsu records each operation that modifies the repo in the \"operation log\". You can see the log with jj op log. Each operation object contains a snapshot of how the repo looked at the end of the operation. We call this snapshot a \"view\" object. The view contains information about where each branch, tag, and Git ref (in Git-backed repos) pointed, as well as the set of heads in the repo, and the current working-copy commit in each workspace. The operation object also (in addition to the view) contains pointers to the operation(s) immediately before it, as well as metadata about the operation, such as timestamps, username, hostname, description.

    The operation log allows you to undo an operation (jj [op] undo), which doesn't need to be the most recent one. It also lets you restore the entire repo to the way it looked at an earlier point (jj op restore).

    When referring to operations, you can use @ to represent the current operation.

    The following operators are supported:

    • x-: Parents of x (e.g. @-)
    • x+: Children of x
    "},{"location":"operation-log/#concurrent-operations","title":"Concurrent operations","text":"

    One benefit of the operation log (and the reason for its creation) is that it allows lock-free concurrency -- you can run concurrent jj commands without corrupting the repo, even if you run the commands on different machines that access the repo via a distributed file system (as long as the file system guarantees that a write is only visible once previous writes are visible). When you run a jj command, it will start by loading the repo at the latest operation. It will not see any changes written by concurrent commands. If there are conflicts, you will be informed of them by subsequent jj st and/or jj log commands.

    As an example, let's say you had started editing the description of a change and then also update the contents of the change (maybe because you had forgotten the editor). When you eventually close your editor, the command will succeed and e.g. jj log will indicate that the change has diverged.

    "},{"location":"operation-log/#loading-an-old-version-of-the-repo","title":"Loading an old version of the repo","text":"

    The top-level --at-operation/--at-op option allows you to load the repo at a specific operation. This can be useful for understanding how your repo got into the current state. It can be even more useful for understanding why someone else's repo got into its current state.

    When you use --at-op, the automatic snapshotting of the working copy will not take place. When referring to a revision with the @ symbol (as many commands do by default), that will resolve to the working-copy commit recorded in the operation's view (which is actually how it always works -- it's just the snapshotting that's skipped with --at-op).

    As a top-level option, --at-op can be passed to any command. However, you will typically only want to run read-only commands. For example, jj log, jj st, and jj diff all make sense. It's still possible to run e.g. jj --at-op=<some operation ID> describe. That's equivalent to having started jj describe back when the specified operation was the most recent operation and then let it run until now (which can be done for that particular command by not closing the editor). There's practically no good reason to do that other than to simulate concurrent commands.

    "},{"location":"related-work/","title":"Related work","text":"

    Similar tools:

    • git-branchless: Helps you use a branchless workflow in your Git repo. Supports anonymous branching, undo, and faster rebase (git move). Under heavy development and quickly gaining new features.
    • Sapling: A heavily modified fork of Mercurial developed and used at Meta. It is compatible with Git, has undo functionality, and a graphical interface. See how it is different from Jujutsu.
    • GitUp: A Mac-only GUI for Git. Like Jujutsu, supports undo and restoring the repo to an earlier snapshot. Backed by its GitUpKit library.
    • Gitless: Another attempt at providing a simpler interface for Git. Like Jujutsu, does not have an \"index\"/\"staging area\" concept. Also doesn't move the working-copy changes between branches (which we do simply as a consequence of making the working copy a commit).
    • Pijul: Architecturally quite different from Jujutsu, but its \"first-class conflicts\" feature seems quite similar to ours.
    • Breezy: Another VCS that's similar in that it has multiple storage backends, including its own format as well as .git support.
    • Sturdy: A Git backed GUI that eliminates local and remote as well as the idea of an \"index\"/\"staging area\".
    "},{"location":"revsets/","title":"Revsets","text":"

    Jujutsu supports a functional language for selecting a set of revisions. Expressions in this language are called \"revsets\" (the idea comes from Mercurial). The language consists of symbols, operators, and functions.

    Most jj commands accept a revset (or multiple). Many commands, such as jj diff -r <revset> expect the revset to resolve to a single commit; it is an error to pass a revset that resolves to more than one commit (or zero commits) to such commands.

    The words \"revisions\" and \"commits\" are used interchangeably in this document.

    Most revsets search only the visible commits. Other commits are only included if you explicitly mention them (e.g. by commit ID or a Git ref pointing to them).

    "},{"location":"revsets/#symbols","title":"Symbols","text":"

    The @ expression refers to the working copy commit in the current workspace. Use <workspace name>@ to refer to the working-copy commit in another workspace. Use <name>@<remote> to refer to a remote-tracking branch.

    A full commit ID refers to a single commit. A unique prefix of the full commit ID can also be used. It is an error to use a non-unique prefix.

    A full change ID refers to all visible commits with that change ID (there is typically only one visible commit with a given change ID). A unique prefix of the full change ID can also be used. It is an error to use a non-unique prefix.

    Use double quotes to prevent a symbol from being interpreted as an expression. For example, \"x-\" is the symbol x-, not the parents of symbol x. Taking shell quoting into account, you may need to use something like jj log -r '\"x-\"'.

    "},{"location":"revsets/#priority","title":"Priority","text":"

    Jujutsu attempts to resolve a symbol in the following order:

    1. Tag name
    2. Branch name
    3. Git ref
    4. Commit ID or change ID
    "},{"location":"revsets/#operators","title":"Operators","text":"

    The following operators are supported. x and y below can be any revset, not only symbols.

    • x & y: Revisions that are in both x and y.
    • x | y: Revisions that are in either x or y (or both).
    • x ~ y: Revisions that are in x but not in y.
    • ~x: Revisions that are not in x.
    • x-: Parents of x.
    • x+: Children of x.
    • ::x: Ancestors of x, including the commits in x itself.
    • x::: Descendants of x, including the commits in x itself.
    • x::y: Descendants of x that are also ancestors of y. Equivalent to x:: & ::y. This is what git log calls --ancestry-path x..y.
    • ::: All visible commits in the repo. Equivalent to all().
    • x..y: Ancestors of y that are not also ancestors of x. Equivalent to ::y ~ ::x. This is what git log calls x..y (i.e. the same as we call it).
    • ..x: Ancestors of x, including the commits in x itself, but excluding the root commit. Equivalent to ::x ~ root().
    • x..: Revisions that are not ancestors of x.
    • ..: All visible commits in the repo, but excluding the root commit. Equivalent to ~root().

    You can use parentheses to control evaluation order, such as (x & y) | z or x & (y | z).

    "},{"location":"revsets/#functions","title":"Functions","text":"

    You can also specify revisions by using functions. Some functions take other revsets (expressions) as arguments.

    • parents(x): Same as x-.

    • children(x): Same as x+.

    • ancestors(x[, depth]): ancestors(x) is the same as ::x. ancestors(x, depth) returns the ancestors of x limited to the given depth.

    • descendants(x): Same as x::.

    • connected(x): Same as x::x. Useful when x includes several commits.

    • all(): All visible commits in the repo.

    • none(): No commits. This function is rarely useful; it is provided for completeness.

    • branches([pattern]): All local branch targets. If pattern is specified, this selects the branches whose name match the given string pattern. For example, branches(push) would match the branches push-123 and repushed but not the branch main. If a branch is in a conflicted state, all its possible targets are included.

    • remote_branches([branch_pattern[, [remote=]remote_pattern]]): All remote branch targets across all remotes. If just the branch_pattern is specified, the branches whose names match the given string pattern across all remotes are selected. If both branch_pattern and remote_pattern are specified, the selection is further restricted to just the remotes whose names match remote_pattern.

      For example, remote_branches(push, ri) would match the branches push-123@origin and repushed@private but not push-123@upstream or main@origin or main@upstream. If a branch is in a conflicted state, all its possible targets are included.

      While Git-tracking branches can be selected by <name>@git, these branches aren't included in remote_branches().

    • tags(): All tag targets. If a tag is in a conflicted state, all its possible targets are included.

    • git_refs(): All Git ref targets as of the last import. If a Git ref is in a conflicted state, all its possible targets are included.

    • git_head(): The Git HEAD target as of the last import. Equivalent to present(HEAD@git).

    • visible_heads(): All visible heads (same as heads(all())).

    • root(): The virtual commit that is the oldest ancestor of all other commits.

    • heads(x): Commits in x that are not ancestors of other commits in x. Note that this is different from Mercurial's heads(x) function, which is equivalent to x ~ x-.

    • roots(x): Commits in x that are not descendants of other commits in x. Note that this is different from Mercurial's roots(x) function, which is equivalent to x ~ x+.

    • latest(x[, count]): Latest count commits in x, based on committer timestamp. The default count is 1.

    • merges(): Merge commits.

    • description(pattern): Commits that have a description matching the given string pattern.

    • author(pattern): Commits with the author's name or email matching the given string pattern.

    • mine(): Commits where the author's email matches the email of the current user.

    • committer(pattern): Commits with the committer's name or email matching the given string pattern.

    • empty(): Commits modifying no files. This also includes merges() without user modifications and root().

    • file(relativepath) or file(\"relativepath\"[, \"relativepath\"]...): Commits modifying one of the paths specified. Currently, string patterns are not supported in the path arguments.

      Paths are relative to the directory jj was invoked from. A directory name will match all files in that directory and its subdirectories.

      For example, file(foo) will match files foo, foo/bar, foo/bar/baz. It will not match foobar or bar/foo.

    • conflict(): Commits with conflicts.

    • present(x): Same as x, but evaluated to none() if any of the commits in x doesn't exist (e.g. is an unknown branch name.)

    "},{"location":"revsets/#string-patterns","title":"String patterns","text":"

    Functions that perform string matching support the following pattern syntax:

    • \"string\", or string (the quotes are optional), or substring:\"string\": Matches strings that contain string.
    • exact:\"string\": Matches strings exactly equal to string.
    • glob:\"pattern\": Matches strings with Unix-style shell wildcard pattern.
    "},{"location":"revsets/#aliases","title":"Aliases","text":"

    New symbols and functions can be defined in the config file, by using any combination of the predefined symbols/functions and other aliases.

    For example:

    [revset-aliases]\n'HEAD' = '@-'\n'user(x)' = 'author(x) | committer(x)'\n
    "},{"location":"revsets/#built-in-aliases","title":"Built-in Aliases","text":"

    The following aliases are built-in and used for certain operations. These functions are defined as aliases in order to allow you to overwrite them as needed. See revsets.toml for a comprehensive list.

    • trunk(): Resolves to the head commit for the trunk branch of the remote named origin or upstream. The branches main, master, and trunk are tried. If more than one potential trunk commit exists, the newest one is chosen. If none of the branches exist, the revset evaluates to root().

      You can override this as appropriate. If you do, make sure it always resolves to exactly one commit. For example:

      [revset-aliases]\n'trunk()' = 'your-branch@your-remote'\n
    • immutable_heads(): Resolves to trunk() | tags() by default. See here for details.

    "},{"location":"revsets/#examples","title":"Examples","text":"

    Show the parent(s) of the working-copy commit (like git log -1 HEAD):

    jj log -r @-\n

    Show all ancestors of the working copy (like plain git log)

    jj log -r ::@\n

    Show commits not on any remote branch:

    jj log -r 'remote_branches()..'\n

    Show commits not on origin (if you have other remotes like fork):

    jj log -r 'remote_branches(remote=origin)..'\n

    Show the initial commits in the repo (the ones Git calls \"root commits\"):

    jj log -r root()+\n

    Show some important commits (like git --simplify-by-decoration):

    jj log -r 'tags() | branches()'\n

    Show local commits leading up to the working copy, as well as descendants of those commits:

    jj log -r '(remote_branches()..@)::'\n

    Show commits authored by \"martinvonz\" and containing the word \"reset\" in the description:

    jj log -r 'author(martinvonz) & description(reset)'\n
    "},{"location":"sapling-comparison/","title":"Comparison with Sapling","text":""},{"location":"sapling-comparison/#introduction","title":"Introduction","text":"

    This document attempts to describe how jj is different from Sapling. Sapling is a VCS developed by Meta. It is a heavily modified fork of Mercurial. Because jj has copied many ideas from Mercurial, there are many similarities between the two tools, such as:

    • A user-friendly CLI
    • A \"revset\" language for selecting revisions
    • Good support for working with stacked commits, including tracking \"anonymous heads\" (no \"detached HEAD\" state like in Git) and split commands, and automatically rebasing descendant commits when you amend a commit.
    • Flexible customization of output using templates
    "},{"location":"sapling-comparison/#differences","title":"Differences","text":"

    Here is a list of some differences between jj and Sapling.

    • Working copy: When using Sapling (like most VCSs), the user explicitly tells the tool when to create a commit and which files to include. When using jj, the working copy is automatically snapshotted by every command. New files are automatically tracked and deleted files are automatically untracked. This has several advantages:

      • The working copy is effectively backed up every time you run a command.
      • No commands fail because you have changes in the working copy (\"abort: 1 conflicting file changes: ...\"). No need for sl shelve.
      • Simpler and more consistent CLI because the working copy is treated like any other commit.
    • Conflicts: Like most VCSs, Sapling requires the user to resolve conflicts before committing. jj lets you commit conflicts. Note that it's a representation of the conflict that's committed, not conflict markers (<<<<<<< etc.). This also has several advantages:

      • Merge conflicts won't prevent you from checking out another commit.
      • You can resolve the conflicts when you feel like it.
      • Rebasing descendants always succeeds. Like jj, Sapling automatically rebases, but it will fail if there are conflicts.
      • Merge commits can be rebased correctly (Sapling sometimes fails).
      • You can rebase conflicts and conflict resolutions.
    • Undo: jj's undo is powered by the operation log, which records how the repo has changed over time. Sapling has a similar feature with its MetaLog. They seem to provide similar functionality, but jj also exposes the log to the user via jj op log, so you can tell how far back you want to go back. Sapling has sl debugmetalog, but that seems to show the history of a single commit, not the whole repo's history. Thanks to jj snapshotting the working copy, it's possible to undo changes to the working copy. For example, if you jj undo a jj commit, jj diff will show the same changes as before jj commit, but if you sl undo a sl commit, the working copy will be clean.

    • Git interop: Sapling supports cloning, pushing, and pulling from a remote Git repo. jj also does, and it also supports sharing a working copy with a Git repo, so you can use jj and git interchangeably in the same repo.
    • Polish: Sapling is much more polished and feature-complete. For example, jj has no blame/annotate or bisect commands, and also no copy/rename support. Sapling also has very nice web UI called Interactive Smartlog, which lets you drag and drop commits to rebase them, among other things.
    • Forge workflow: Sapling has sl pr submit --stack, which lets you push a stack of commits as separate GitHub PRs, including setting the base branch. It only supports GitHub. jj doesn't have any direct integration with GitHub or any other forge. However, it has jj git push --change for automatically creating branches for specified commits. You have to specify each commit you want to create a branch for by using jj git push --change X --change Y ..., and you have to manually set up any base branches in GitHub's UI (or GitLab's or ...). On subsequent pushes, you can update all at once by specifying something like jj git push -r main..@ (to push all branches on the current stack of commits from where it forked from main).
    "},{"location":"templates/","title":"Templates","text":"

    Jujutsu supports a functional language to customize output of commands. The language consists of literals, keywords, operators, functions, and methods.

    A couple of jj commands accept a template via -T/--template option.

    "},{"location":"templates/#keywords","title":"Keywords","text":"

    Keywords represent objects of different types; the types are described in a follow-up section. In addition to context-specific keywords, the top-level object can be referenced as self.

    "},{"location":"templates/#commit-keywords","title":"Commit keywords","text":"

    In jj log/jj obslog templates, all 0-argument methods of the Commit type are available as keywords. For example, commit_id is equivalent to self.commit_id().

    "},{"location":"templates/#operation-keywords","title":"Operation keywords","text":"

    In jj op log templates, all 0-argument methods of the Operation type are available as keywords. For example, current_operation is equivalent to self.current_operation().

    "},{"location":"templates/#operators","title":"Operators","text":"

    The following operators are supported.

    • x.f(): Method call.
    • -x: Negate integer value.
    • !x: Logical not.
    • x && y: Logical and, short-circuiting.
    • x || y: Logical or, short-circuiting.
    • x ++ y: Concatenate x and y templates.
    "},{"location":"templates/#global-functions","title":"Global functions","text":"

    The following functions are defined.

    • fill(width: Integer, content: Template) -> Template: Fill lines at the given width.
    • indent(prefix: Template, content: Template) -> Template: Indent non-empty lines by the given prefix.
    • label(label: Template, content: Template) -> Template: Apply label to the content. The label is evaluated as a space-separated string.
    • if(condition: Boolean, then: Template[, else: Template]) -> Template: Conditionally evaluate then/else template content.
    • coalesce(content: Template...) -> Template: Returns the first non-empty content.
    • concat(content: Template...) -> Template: Same as content_1 ++ ... ++ content_n.
    • separate(separator: Template, content: Template...) -> Template: Insert separator between non-empty contents.
    • surround(prefix: Template, suffix: Template, content: Template) -> Template: Surround non-empty content with texts such as parentheses.
    "},{"location":"templates/#types","title":"Types","text":""},{"location":"templates/#boolean-type","title":"Boolean type","text":"

    No methods are defined. Can be constructed with false or true literal.

    "},{"location":"templates/#commit-type","title":"Commit type","text":"

    This type cannot be printed. The following methods are defined.

    • description() -> String
    • change_id() -> ChangeId
    • commit_id() -> CommitId
    • parents() -> List<Commit>
    • author() -> Signature
    • committer() -> Signature
    • working_copies() -> String: For multi-workspace repository, indicate working-copy commit as <workspace name>@.
    • current_working_copy() -> Boolean: True for the working-copy commit of the current workspace.
    • branches() -> List<RefName>: Local and remote branches pointing to the commit. A tracking remote branch will be included only if its target is different from the local one.
    • local_branches() -> List<RefName>: All local branches pointing to the commit.
    • remote_branches() -> List<RefName>: All remote branches pointing to the commit.
    • tags() -> List<RefName>
    • git_refs() -> List<RefName>
    • git_head() -> Option<RefName>
    • divergent() -> Boolean: True if the commit's change id corresponds to multiple visible commits.
    • hidden() -> Boolean: True if the commit is not visible (a.k.a. abandoned).
    • immutable() -> Boolean: True if the commit is included in the set of immutable commits.
    • conflict() -> Boolean: True if the commit contains merge conflicts.
    • empty() -> Boolean: True if the commit modifies no files.
    • root() -> Boolean: True if the commit is the root commit.
    "},{"location":"templates/#commitid-changeid-type","title":"CommitId / ChangeId type","text":"

    The following methods are defined.

    • .short([len: Integer]) -> String
    • .shortest([min_len: Integer]) -> ShortestIdPrefix: Shortest unique prefix.
    "},{"location":"templates/#integer-type","title":"Integer type","text":"

    No methods are defined.

    "},{"location":"templates/#list-type","title":"List type","text":"

    A list can be implicitly converted to Boolean. The following methods are defined.

    • .len() -> Integer: Number of elements in the list.
    • .join(separator: Template) -> Template: Concatenate elements with the given separator.
    • .map(|item| expression) -> ListTemplate: Apply template expression to each element. Example: parents.map(|c| c.commit_id().short())
    "},{"location":"templates/#listtemplate-type","title":"ListTemplate type","text":"

    The following methods are defined. See also the List type.

    • .join(separator: Template) -> Template
    "},{"location":"templates/#operation-type","title":"Operation type","text":"

    This type cannot be printed. The following methods are defined.

    • current_operation() -> Boolean
    • description() -> String
    • id() -> OperationId
    • tags() -> String
    • time() -> TimestampRange
    • user() -> String
    • root() -> Boolean: True if the commit is the root commit.
    "},{"location":"templates/#operationid-type","title":"OperationId type","text":"

    The following methods are defined.

    • .short([len: Integer]) -> String
    "},{"location":"templates/#option-type","title":"Option type","text":"

    An option can be implicitly converted to Boolean denoting whether the contained value is set. If set, all methods of the contained value can be invoked. If not set, an error will be reported inline on method call.

    "},{"location":"templates/#refname-type","title":"RefName type","text":"

    The following methods are defined.

    • .name() -> String: Local branch or tag name.
    • .remote() -> String: Remote name or empty if this is a local ref.
    "},{"location":"templates/#shortestidprefix-type","title":"ShortestIdPrefix type","text":"

    The following methods are defined.

    • .prefix() -> String
    • .rest() -> String
    • .upper() -> ShortestIdPrefix
    • .lower() -> ShortestIdPrefix
    "},{"location":"templates/#signature-type","title":"Signature type","text":"

    The following methods are defined.

    • .name() -> String
    • .email() -> String
    • .username() -> String
    • .timestamp() -> Timestamp
    "},{"location":"templates/#string-type","title":"String type","text":"

    A string can be implicitly converted to Boolean. The following methods are defined.

    • .len() -> Integer: Length in UTF-8 bytes.
    • .contains(needle: Template) -> Boolean
    • .first_line() -> String
    • .lines() -> List<String>: Split into lines excluding newline characters.
    • .upper() -> String
    • .lower() -> String
    • .starts_with(needle: Template) -> Boolean
    • .ends_with(needle: Template) -> Boolean
    • .remove_prefix(needle: Template) -> String: Removes the passed prefix, if present
    • .remove_suffix(needle: Template) -> String: Removes the passed suffix, if present
    • .substr(start: Integer, end: Integer) -> String: Extract substring. The start/end indices should be specified in UTF-8 bytes. Negative values count from the end of the string.
    "},{"location":"templates/#string-literals","title":"String literals","text":"

    String literals must be surrounded by double quotes (\"). The following escape sequences starting with a backslash have their usual meaning: \\\", \\\\, \\n, \\r, \\t, \\0. Other escape sequences are not supported. Any UTF-8 characters are allowed inside a string literal, with two exceptions: unescaped \"-s and uses of \\ that don't form a valid escape sequence.

    "},{"location":"templates/#template-type","title":"Template type","text":"

    Most types can be implicitly converted to Template. No methods are defined.

    "},{"location":"templates/#timestamp-type","title":"Timestamp type","text":"

    The following methods are defined.

    • .ago() -> String: Format as relative timestamp.
    • .format(format: String) -> String: Format with the specified strftime-like format string.
    • .utc() -> Timestamp: Convert timestamp into UTC timezone.
    • .local() -> Timestamp: Convert timestamp into local timezone.
    "},{"location":"templates/#timestamprange-type","title":"TimestampRange type","text":"

    The following methods are defined.

    • .start() -> Timestamp
    • .end() -> Timestamp
    • .duration() -> String
    "},{"location":"templates/#configuration","title":"Configuration","text":"

    The default templates and aliases() are defined in the [templates] and [template-aliases] sections of the config respectively. The exact definitions can be seen in the cli/src/config/templates.toml file in jj's source tree.

    New keywords and functions can be defined as aliases, by using any combination of the predefined keywords/functions and other aliases.

    For example:

    [template-aliases]\n'commit_change_ids' = '''\nconcat(\n  format_field(\"Commit ID\", commit_id),\n  format_field(\"Change ID\", commit_id),\n)\n'''\n'format_field(key, value)' = 'key ++ \": \" ++ value ++ \"\\n\"'\n
    "},{"location":"testimonials/","title":"Testimonials","text":"

    You might not be ready to make the jump to Jujutsu yet. It's understandable; new tools come with new lessons, failures, and ideas to absorb. They require practice. In order to provide some motivation, we've collected a number of real, 100% authentic testimonials \u2014 from our loving users, our silly developers \u2014 all to tip the scales and get you on our side!

    "},{"location":"testimonials/#what-the-users-have-to-say","title":"What the users have to say","text":"

    I've spent many years of my career working on version control. What I like most about Jujutsu is how it has non-obvious solutions to UX problems that we've run into in the past. What most people may not realize is that there are many novel features which all interlock to make it easy to use.

    For example, consider Jujutsu's support for automatically rebasing descendants of amended revisions. When we implemented that in Mercurial, we ran into an issue: what if there's a merge conflict? Our solution was to warn users and just not perform the auto-rebase. Now, suddenly, users have to understand that there can be old versions of the same revision visible in their log, and learn how to fix this state.

    In contrast, Jujutsu's solution is to simply make merge conflicts first-class. This is not just an improvement in general, it is also specifically an improvement for auto-rebase \u2014 users no longer have to learn about old versions of a revision unless they want to look at the obslog.

    Over and over, I'm struck by how well Jujutsu demonstrates this kind of evolved thinking, which as an experienced version control developer I deeply appreciate.

    \u2014 Rain, engineer at Oxide Computer Company, former VCS developer

    Jujutsu is amazing... I couldn't have come up with anything remotely as elegant.

    It's so rare that a solution attacks the innermost core of a problem so thoroughly, I genuinely feel blessed to be in its presence. And also a bit vindicated in not even trying to learn to use any of the tools that felt like more crutches stacked upon a sand castle

    \u2014 Anonymous user, speaking from the shadows

    It's the easiest time I've ever had learning a tool this deeply this quickly, because of the ability to experiment and undo, instead of triple-checking before trying a new scary command.

    \u2014 Scott Olson, advanced Git user and now a Jujutsu user

    I initially started to use Jujutsu for personal repos, and it has quickly gone from \"neat, let's try this more\" to \"very neat, added to my permanent config and automatically installed for new machines\".

    \u2014 Poliorcetics, on GitHub

    when i worked on the rust compiler, my job was to chain together a bunch of strange and cursed tools that broke often. jujutsu breaks about half as much, so that's pretty good i guess

    \u2014 jyn514, Rust contributor

    Jujutsu is pretty cool, you can even keep most of your existing workflows

    \u2014 Ben, who doesn't want you keeping your existing workflow

    Wait, it's not called Jujitsu?

    \u2014 Phil, Mercurial contributor (who doesn't have to learn Git, now that Jujutsu exists)

    When I heard about Jujutsu I decided to try it out before forming an opinion. Technically it never formed, because I haven't considered going back.

    \u2014 gul banana, computer programmer

    "},{"location":"testimonials/#what-the-developers-have-to-say","title":"What the developers have to say","text":"

    I've been a FOSS contributor using Git for over 16 years, and Jujutsu continues to amaze me every day. It has that sweet simplicity I was fond of in Darcs, but it boils down all my most core and fundamental workflows \u2014 developed over years of experience \u2014 into a simple set of primitives. The internal design is simple and beautiful; it looks like a database, making the implementation elegant, safe, and extensible. All this, using the same Git repositories my coworkers use.

    It's like if you found out one day that you built your entire home on a vein of rich gold. Every day I seem to find new and beautiful emergent behaviors, all adding up to a tool that is greater than the sum of its parts.

    \u2014 Austin Seipp, \"No 1. Jujutsu Fan\"

    Honestly, I implemented signing support mostly for that sweet dopamine hit that you get from the green checkmark on GitHub. Yeah.

    \u2014 Anton Bulakh, contributor and dopamine enthusiast

    I'm sometimes still surprised that navigating with jj next and jj prev works.

    \u2014 Philip Metzger, author of jj next and jj prev

    I'm surprised when it works.

    \u2014 Martin von Zweigbergk, project creator and leader

    "},{"location":"testimonials/#spread-the-word-yourself","title":"Spread the word yourself","text":"

    Are you satisfied with Jujutsu? Ready to recommend it to a Jujillion of your friends and coworkers? Great! The easiest way to help the project grow is word of mouth. So make sure to talk to them about it and show off your hip new tool. Maybe post a link to it on your other favorite tool that you love using, Slack?

    If you're not sure what to say, we hired the cheapest marketing team we could find to design a list of Pre-Approved Endorsements in their laboratory. Just copy and paste these right into a text box! Shilling for an open source project has never been easier than this.

    Jujutsu is an alright tool. I guess.

    Jujutsu is my favorite software tool of all time. I am saying this for no particular reason, definitely not because I was paid to.

    I love Jujutsu. I love Jujutsu. I love Jujutsu. I love Jujutsu. I love Jujutsu. I love Jujutsu. I love Jujutsu. I love Jujutsu.

    "},{"location":"tutorial/","title":"Tutorial","text":"

    This text assumes that the reader is familiar with Git.

    "},{"location":"tutorial/#preparation","title":"Preparation","text":"

    If you haven't already, make sure you install and configure Jujutsu.

    "},{"location":"tutorial/#cloning-a-git-repo","title":"Cloning a Git repo","text":"

    Let's start by cloning GitHub's Hello-World repo using jj:

    # Note the \"git\" before \"clone\" (there is no support for cloning native jj\n# repos yet)\n$ jj git clone https://github.com/octocat/Hello-World\nFetching into new repo in \"/tmp/tmp.O1DWMiaKd4/Hello-World\"\nWorking copy now at: kntqzsqt d7439b06 (empty) (no description set)\nParent commit      : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1\nAdded 1 files, modified 0 files, removed 0 files\n$ cd Hello-World\n

    Running jj st (short for jj status) now yields something like this:

    $ jj st\nThe working copy is clean\nWorking copy : kntqzsqt d7439b06 (empty) (no description set)\nParent commit: orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1\n

    We can see from the output above that our working copy is a real commit with a commit ID (d7439b06 in the example). When you make a change in the working copy, the working-copy commit gets automatically amended by the next jj command.

    "},{"location":"tutorial/#creating-our-first-change","title":"Creating our first change","text":"

    Now let's say we want to edit the README file in the repo to say \"Goodbye\" instead of \"Hello\". Let's start by describing the change (adding a commit message) so we don't forget what we're working on:

    # This will bring up $EDITOR (or `pico` or `Notepad` by default). Enter\n# something like \"Say goodbye\" in the editor and then save the file and close\n# the editor.\n$ jj describe\nWorking copy now at: kntqzsqt e427edcf (empty) Say goodbye\nParent commit      : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1\n

    Now make the change in the README:

    # Adjust as necessary for compatibility with your flavor of `sed`\n$ sed -i 's/Hello/Goodbye/' README\n$ jj st\nWorking copy changes:\nM README\nWorking copy : kntqzsqt 5d39e19d Say goodbye\nParent commit: orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1\n

    Note that you didn't have to tell Jujutsu to add the change like you would with git add. You actually don't even need to tell it when you add new files or remove existing files. To untrack a path, add it to your .gitignore and run jj untrack <path>.

    To see the diff, run jj diff:

    $ jj diff --git  # Feel free to skip the `--git` flag\ndiff --git a/README b/README\nindex 980a0d5f19...1ce3f81130 100644\n--- a/README\n+++ b/README\n@@ -1,1 +1,1 @@\n-Hello World!\n+Goodbye World!\n

    Jujutsu's diff format currently defaults to inline coloring of the diff (like git diff --color-words), so we used --git above to make the diff readable in this tutorial.

    As you may have noticed, the working-copy commit's ID changed both when we edited the description and when we edited the README. However, the parent commit stayed the same. Each change to the working-copy commit amends the previous version. So how do we tell Jujutsu that we are done amending the current change and want to start working on a new one? That is what jj new is for. That will create a new commit on top of your current working-copy commit. The new commit is for the working-copy changes.

    So, let's say we're now done with this change, so we create a new change:

    $ jj new\nWorking copy now at: mpqrykyp aef4df99 (empty) (no description set)\nParent commit      : kntqzsqt 5d39e19d Say goodbye\n$ jj st\nThe working copy is clean\nWorking copy : mpqrykyp aef4df99 (empty) (no description set)\nParent commit: kntqzsqt 5d39e19d Say goodbye\n

    If we later realize that we want to make further changes, we can make them in the working copy and then run jj squash. That command squashes the changes from a given commit into its parent commit. Like most commands, it acts on the working-copy commit by default. When run on the working-copy commit, it behaves very similar to git commit --amend, and jj amend is in fact an alias for jj squash.

    Alternatively, we can use jj edit <commit> to resume editing a commit in the working copy. Any further changes in the working copy will then amend the commit. Whether you choose to create a new change and squash, or to edit, typically depends on how done you are with the change; if the change is almost done, it makes sense to use jj new so you can easily review your adjustments with jj diff before running jj squash.

    "},{"location":"tutorial/#the-log-command-and-revsets","title":"The log command and \"revsets\"","text":"

    You're probably familiar with git log. Jujutsu has very similar functionality in its jj log command:

    $ jj log\n@  mpqrykyp martinvonz@google.com 2023-02-12 15:00:22.000 -08:00 aef4df99\n\u2502  (empty) (no description set)\n\u25c9  kntqzsqt martinvonz@google.com 2023-02-12 14:56:59.000 -08:00 5d39e19d\n\u2502  Say goodbye\n\u2502 \u25c9  tpstlust support+octocat@github.com 2018-05-10 12:55:19.000 -05:00 octocat-patch-1@origin b1b3f972\n\u251c\u2500\u256f  sentence case\n\u2502 \u25c9  kowxouwz octocat@nowhere.com 2014-06-10 15:22:26.000 -07:00 test@origin b3cbd5bb\n\u251c\u2500\u256f  Create CONTRIBUTING.md\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2502  (empty) Merge pull request #6 from Spaceghost/patch-1\n~\n

    The @ indicates the working-copy commit. The first ID on a line (e.g. \"mpqrykyp\" above) is the \"change ID\", which is an ID that follows the commit as it's rewritten (similar to Gerrit's Change-Id). The second ID is the commit ID, which changes when you rewrite the commit. You can give either ID to commands that take revisions as arguments. We will generally prefer change IDs because they stay the same when the commit is rewritten.

    By default, jj log lists your local commits, with some remote commits added for context. The ~ indicates that the commit has parents that are not included in the graph. We can use the --revisions/-r flag to select a different set of revisions to list. The flag accepts a \"revset\", which is an expression in a simple language for specifying revisions. For example, @ refers to the working-copy commit, root() refers to the root commit, branches() refers to all commits pointed to by branches. We can combine expressions with | for union, & for intersection and ~ for difference. For example:

    $ jj log -r '@ | root() | branches()'\n@  mpqrykyp martinvonz@google.com 2023-02-12 15:00:22.000 -08:00 aef4df99\n\u2577  (empty) (no description set)\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2577  (empty) Merge pull request #6 from Spaceghost/patch-1\n\u25c9  zzzzzzzz root() 00000000\n

    The 00000000 commit (change ID zzzzzzzz) is a virtual commit that's called the \"root commit\". It's the root commit of every repo. The root() function in the revset matches it.

    There are also operators for getting the parents (foo-), children (foo+), ancestors (::foo), descendants (foo::), DAG range (foo::bar, like git log --ancestry-path), range (foo..bar, same as Git's). See the revset documentation for all revset operators and functions.

    "},{"location":"tutorial/#conflicts","title":"Conflicts","text":"

    Now let's see how Jujutsu deals with merge conflicts. We'll start by making some commits. We use jj new with the --message/-m option to set change descriptions (commit messages) right away.

    # Start creating a chain of commits off of the `master` branch\n$ jj new master -m A; echo a > file1\nWorking copy now at: nuvyytnq 00a2aeed (empty) A\nParent commit      : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1\nAdded 0 files, modified 1 files, removed 0 files\n$ jj new -m B1; echo b1 > file1\nWorking copy now at: ovknlmro 967d9f9f (empty) B1\nParent commit      : nuvyytnq 5dda2f09 A\n$ jj new -m B2; echo b2 > file1\nWorking copy now at: puqltutt 8ebeaffa (empty) B2\nParent commit      : ovknlmro 7d7c6e6b B1\n$ jj new -m C; echo c > file2\nWorking copy now at: qzvqqupx 62a3c6d3 (empty) C\nParent commit      : puqltutt daa6ffd5 B2\n$ jj log\n@  qzvqqupx martinvonz@google.com 2023-02-12 15:07:41.946 -08:00 2370ddf3\n\u2502  C\n\u25c9  puqltutt martinvonz@google.com 2023-02-12 15:07:33.000 -08:00 daa6ffd5\n\u2502  B2\n\u25c9  ovknlmro martinvonz@google.com 2023-02-12 15:07:24.000 -08:00 7d7c6e6b\n\u2502  B1\n\u25c9  nuvyytnq martinvonz@google.com 2023-02-12 15:07:05.000 -08:00 5dda2f09\n\u2502  A\n\u2502 \u25c9  kntqzsqt martinvonz@google.com 2023-02-12 14:56:59.000 -08:00 5d39e19d\n\u251c\u2500\u256f  Say goodbye\n\u2502 \u25c9  tpstlust support+octocat@github.com 2018-05-10 12:55:19.000 -05:00 octocat-patch-1@origin b1b3f972\n\u251c\u2500\u256f  sentence case\n\u2502 \u25c9  kowxouwz octocat@nowhere.com 2014-06-10 15:22:26.000 -07:00 test@origin b3cbd5bb\n\u251c\u2500\u256f  Create CONTRIBUTING.md\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2502  (empty) Merge pull request #6 from Spaceghost/patch-1\n~\n

    We now have a few commits, where A, B1, and B2 modify the same file, while C modifies a different file. Let's now rebase B2 directly onto A. We use the --source/-s option on the change ID of B2, and --destination/-d option on A.

    $ jj rebase -s puqltutt -d nuvyytnq  # Replace the IDs by what you have for B2 and A\nRebased 2 commits\nNew conflicts appeared in these commits:\n  qzvqqupx 1978b534 (conflict) C\n  puqltutt f7fb5943 (conflict) B2\nTo resolve the conflicts, start by updating to the first one:\n  jj new puqltuttzvly\nThen use `jj resolve`, or edit the conflict markers in the file directly.\nOnce the conflicts are resolved, you may want inspect the result with `jj diff`.\nThen run `jj squash` to move the resolution into the conflicted commit.\nWorking copy now at: qzvqqupx 1978b534 (conflict) C\nParent commit      : puqltutt f7fb5943 (conflict) B2\nAdded 0 files, modified 1 files, removed 0 files\n$ jj log\n@  qzvqqupx martinvonz@google.com 2023-02-12 15:08:33.000 -08:00 1978b534 conflict\n\u2502  C\n\u25c9  puqltutt martinvonz@google.com 2023-02-12 15:08:33.000 -08:00 f7fb5943 conflict\n\u2502  B2\n\u2502 \u25c9  ovknlmro martinvonz@google.com 2023-02-12 15:07:24.000 -08:00 7d7c6e6b\n\u251c\u2500\u256f  B1\n\u25c9  nuvyytnq martinvonz@google.com 2023-02-12 15:07:05.000 -08:00 5dda2f09\n\u2502  A\n\u2502 \u25c9  kntqzsqt martinvonz@google.com 2023-02-12 14:56:59.000 -08:00 5d39e19d\n\u251c\u2500\u256f  Say goodbye\n\u2502 \u25c9  tpstlust support+octocat@github.com 2018-05-10 12:55:19.000 -05:00 octocat-patch-1@origin b1b3f972\n\u251c\u2500\u256f  sentence case\n\u2502 \u25c9  kowxouwz octocat@nowhere.com 2014-06-10 15:22:26.000 -07:00 test@origin b3cbd5bb\n\u251c\u2500\u256f  Create CONTRIBUTING.md\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2502  (empty) Merge pull request #6 from Spaceghost/patch-1\n~\n

    There are several things worth noting here. First, the jj rebase command said \"Rebased 2 commits\". That's because we asked it to rebase commit B2 with the -s option, which also rebases descendants (commit C in this case). Second, because B2 modified the same file (and word) as B1, rebasing it resulted in conflicts, as the output indicates. Third, the conflicts did not prevent the rebase from completing successfully, nor did it prevent C from getting rebased on top.

    Now let's resolve the conflict in B2. We'll do that by creating a new commit on top of B2. Once we've resolved the conflict, we'll squash the conflict resolution into the conflicted B2. That might look like this:

    $ jj new puqltutt  # Replace the ID by what you have for B2\nWorking copy now at: zxoosnnp c7068d1c (conflict) (empty) (no description set)\nParent commit      : puqltutt f7fb5943 (conflict) B2\nAdded 0 files, modified 0 files, removed 1 files\n$ jj st\nThe working copy is clean\nThere are unresolved conflicts at these paths:\nfile1    2-sided conflict\nWorking copy : zxoosnnp c7068d1c (conflict) (empty) (no description set)\nParent commit: puqltutt f7fb5943 (conflict) B2\n$ cat file1\n<<<<<<<\n%%%%%%%\n-b1\n+a\n+++++++\nb2\n>>>>>>>\n$ echo resolved > file1\n$ jj squash\nRebased 1 descendant commits\nExisting conflicts were resolved or abandoned from these commits:\n  qzvqqupx hidden 1978b534 (conflict) C\n  puqltutt hidden f7fb5943 (conflict) B2\nWorking copy now at: ntxxqymr e3c279cc (empty) (no description set)\nParent commit      : puqltutt 2c7a658e B2\n$ jj log\n@  ntxxqymr martinvonz@google.com 2023-02-12 19:34:09.000 -08:00 e3c279cc\n\u2502  (empty) (no description set)\n\u2502 \u25c9  qzvqqupx martinvonz@google.com 2023-02-12 19:34:09.000 -08:00 b9da9d28\n\u251c\u2500\u256f  C\n\u25c9  puqltutt martinvonz@google.com 2023-02-12 19:34:09.000 -08:00 2c7a658e\n\u2502  B2\n\u2502 \u25c9  ovknlmro martinvonz@google.com 2023-02-12 15:07:24.000 -08:00 7d7c6e6b\n\u251c\u2500\u256f  B1\n\u25c9  nuvyytnq martinvonz@google.com 2023-02-12 15:07:05.000 -08:00 5dda2f09\n\u2502  A\n\u2502 \u25c9  kntqzsqt martinvonz@google.com 2023-02-12 14:56:59.000 -08:00 5d39e19d\n\u251c\u2500\u256f  Say goodbye\n\u2502 \u25c9  tpstlust support+octocat@github.com 2018-05-10 12:55:19.000 -05:00 octocat-patch-1@origin b1b3f972\n\u251c\u2500\u256f  sentence case\n\u2502 \u25c9  kowxouwz octocat@nowhere.com 2014-06-10 15:22:26.000 -07:00 test@origin b3cbd5bb\n\u251c\u2500\u256f  Create CONTRIBUTING.md\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2502  (empty) Merge pull request #6 from Spaceghost/patch-1\n~\n

    Note that commit C automatically got rebased on top of the resolved B2, and that C is also resolved (since it modified only a different file).

    By the way, if we want to get rid of B1 now, we can run jj abandon ovknlmro. That will hide the commit from the log output and will rebase any descendants to its parent.

    "},{"location":"tutorial/#the-operation-log","title":"The operation log","text":"

    Jujutsu keeps a record of all changes you've made to the repo in what's called the \"operation log\". Use the jj op (short for jj operation) family of commands to interact with it. To list the operations, use jj op log:

    $ jj op log\n@  d3b77addea49 martinvonz@vonz.svl.corp.google.com 3 minutes ago, lasted 3 milliseconds\n\u2502  squash commit 63874fe6c4fba405ffc38b0dd926f03b715cf7ef\n\u2502  args: jj squash\n\u25c9  6fc1873c1180 martinvonz@vonz.svl.corp.google.com 3 minutes ago, lasted 1 milliseconds\n\u2502  snapshot working copy\n\u2502  args: jj squash\n\u25c9  ed91f7bcc1fb martinvonz@vonz.svl.corp.google.com 6 minutes ago, lasted 1 milliseconds\n\u2502  new empty commit\n\u2502  args: jj new puqltutt\n\u25c9  367400773f87 martinvonz@vonz.svl.corp.google.com 12 minutes ago, lasted 3 milliseconds\n\u2502  rebase commit daa6ffd5a09a8a7d09a65796194e69b7ed0a566d and descendants\n\u2502  args: jj rebase -s puqltutt -d nuvyytnq\n[many more lines]\n

    The most useful command is jj undo (alias for jj op undo), which will undo an operation. By default, it will undo the most recent operation. Let's try it:

    $ jj undo\nNew conflicts appeared in these commits:\n  qzvqqupx 1978b534 (conflict) C\n  puqltutt f7fb5943 (conflict) B2\nTo resolve the conflicts, start by updating to the first one:\n  jj new puqltuttzvly\nThen use `jj resolve`, or edit the conflict markers in the file directly.\nOnce the conflicts are resolved, you may want inspect the result with `jj diff`.\nThen run `jj squash` to move the resolution into the conflicted commit.\nWorking copy now at: zxoosnnp 63874fe6 (no description set)\nParent commit      : puqltutt f7fb5943 (conflict) B2\n$ jj log\n@  zxoosnnp martinvonz@google.com 2023-02-12 19:34:09.000 -08:00 63874fe6\n\u2502  (no description set)\n\u2502 \u25c9  qzvqqupx martinvonz@google.com 2023-02-12 15:08:33.000 -08:00 1978b534 conflict\n\u251c\u2500\u256f  C\n\u25c9  puqltutt martinvonz@google.com 2023-02-12 15:08:33.000 -08:00 f7fb5943 conflict\n\u2502  B2\n\u2502 \u25c9  ovknlmro martinvonz@google.com 2023-02-12 15:07:24.000 -08:00 7d7c6e6b\n\u251c\u2500\u256f  B1\n\u25c9  nuvyytnq martinvonz@google.com 2023-02-12 15:07:05.000 -08:00 5dda2f09\n\u2502  A\n\u2502 \u25c9  kntqzsqt martinvonz@google.com 2023-02-12 14:56:59.000 -08:00 5d39e19d\n\u251c\u2500\u256f  Say goodbye\n\u2502 \u25c9  tpstlust support+octocat@github.com 2018-05-10 12:55:19.000 -05:00 octocat-patch-1@origin b1b3f972\n\u251c\u2500\u256f  sentence case\n\u2502 \u25c9  kowxouwz octocat@nowhere.com 2014-06-10 15:22:26.000 -07:00 test@origin b3cbd5bb\n\u251c\u2500\u256f  Create CONTRIBUTING.md\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2502  (empty) Merge pull request #6 from Spaceghost/patch-1\n~\n

    As you can perhaps see, that undid the jj squash invocation we used for squashing the conflict resolution into commit B2 earlier. Notice that it also updated the working copy.

    You can also view the repo the way it looked after some earlier operation. For example, if you want to see jj log output right after the jj rebase operation, try jj log --at-op=367400773f87 but use the hash from your own jj op log.

    "},{"location":"tutorial/#moving-content-changes-between-commits","title":"Moving content changes between commits","text":"

    You have already seen how jj squash can combine the changes from two commits into one. There are several other commands for changing the contents of existing commits.

    We'll need some more complex content to test these commands, so let's create a few more commits:

    $ jj new master -m abc; printf 'a\\nb\\nc\\n' > file\nWorking copy now at: ztqrpvnw f94e49cf (empty) abc\nParent commit      : orrkosyo 7fd1a60b master | (empty) Merge pull request #6 from Spaceghost/patch-1\nAdded 0 files, modified 0 files, removed 1 files\n$ jj new -m ABC; printf 'A\\nB\\nc\\n' > file\nWorking copy now at: kwtuwqnm 6f30cd1f (empty) ABC\nParent commit      : ztqrpvnw 51002261 ab\n$ jj new -m ABCD; printf 'A\\nB\\nC\\nD\\n' > file\nWorking copy now at: mrxqplyk a6749154 (empty) ABCD\nParent commit      : kwtuwqnm 30aecc08 ABC\n$ jj log -r master::@\n@  mrxqplyk martinvonz@google.com 2023-02-12 19:38:21.000 -08:00 b98c607b\n\u2502  ABCD\n\u25c9  kwtuwqnm martinvonz@google.com 2023-02-12 19:38:12.000 -08:00 30aecc08\n\u2502  ABC\n\u25c9  ztqrpvnw martinvonz@google.com 2023-02-12 19:38:03.000 -08:00 51002261\n\u2502  abc\n\u25c9  orrkosyo octocat@nowhere.com 2012-03-06 15:06:50.000 -08:00 master 7fd1a60b\n\u2502  (empty) Merge pull request #6 from Spaceghost/patch-1\n~\n

    We \"forgot\" to capitalize \"c\" in the second commit when we capitalized the other letters. We then fixed that in the third commit when we also added \"D\". It would be cleaner to move the capitalization of \"c\" into the second commit. We can do that by running jj squash with the --interactive/-i option on the third commit. Remember that jj squash moves all the changes from one commit into its parent. jj squash -i moves only part of the changes into its parent. Now try that:

    $ jj squash -i\nUsing default editor ':builtin'; you can change this by setting ui.diff-editor\nWorking copy now at: mrxqplyk 52a6c7fd ABCD\nParent commit      : kwtuwqnm 643061ac ABC\n

    That will bring up the built-in diff editor with a diff of the changes in the \"ABCD\" commit. If you prefer another diff editor, you can configure ui.diff-editor instead. Modify the right side of the diff to have the desired end state in \"ABC\" by removing the \"D\" line. Then save the changes and close Meld. If we look at the diff of the second commit, we now see that all three lines got capitalized:

    $ jj diff -r @-\nModified regular file file:\n   1    1: aA\n   2    2: bB\n   3    3: cC\n

    The child change (\"ABCD\" in our case) will have the same content state after the jj squash command. That means that you can move any changes you want into the parent change, even if they touch the same word, and it won't cause any conflicts.

    Let's try one final command for changing the contents of an exiting commit. That command is jj diffedit, which lets you edit the contents of a commit without checking it out.

    $ jj diffedit -r @-\nUsing default editor ':builtin'; you can change this by setting ui.diff-editor\nCreated kwtuwqnm 70985eaa (empty) ABC\nRebased 1 descendant commits\nNew conflicts appeared in these commits:\n  mrxqplyk 1c72cd50 (conflict) ABCD\nTo resolve the conflicts, start by updating to it:\n  jj new mrxqplykmyqv\nThen use `jj resolve`, or edit the conflict markers in the file directly.\nOnce the conflicts are resolved, you may want inspect the result with `jj diff`.\nThen run `jj squash` to move the resolution into the conflicted commit.\nWorking copy now at: mrxqplyk 1c72cd50 (conflict) ABCD\nParent commit      : kwtuwqnm 70985eaa (empty) ABC\nAdded 0 files, modified 1 files, removed 0 files\n

    In the diff editor, edit the right side by e.g. adding something to the first line. Press 'c' to save the changes and close it. You can now inspect the rewritten commit with jj diff -r @- again and you should see your addition to the first line. Unlike jj squash -i, which left the content state of the commit unchanged, jj diffedit (typically) results in a different state, which means that descendant commits may have conflicts.

    Other commands for rewriting contents of existing commits are jj split, jj unsquash -i. Now that you've seen how jj squash -i and jj diffedit work, you can hopefully figure out how those work (with the help of the instructions in the diff).

    "},{"location":"windows/","title":"Working on Windows","text":"

    Jujutsu works the same on all platforms, but there are some caveats that Windows users should be aware of.

    "},{"location":"windows/#line-endings-are-not-converted","title":"Line endings are not converted","text":"

    Jujutsu does not currently honor .gitattributes and does not have a setting like Git's core.autocrlf. This means that line endings will be checked out exactly as they are committed and committed exactly as authored. This is true on all platforms, but Windows users are most likely to miss CRLF conversion.

    If your Git repository expects Windows users to have core.autocrlf set to true, then the files are committed with LF line endings but are checked out with CRLF line endings. Jujutsu doesn't understand this and will convert the committed line endings to CRLF.

    After creating a colocated repository on Windows, you most likely want to set core.autocrlf to input, then jj abandon to convert all files on disk to LF line endings:

    PS> git config core.autocrlf input\n\n# Abandoning the working copy will cause Jujutsu to overwrite all files with\n# CRLF line endings with the line endings they are committed with, probably LF\nPS> jj abandon\n

    This setting ensures Git will check out files with LF line endings without converting them to CRLF. You'll want to make sure any tooling you use, especially IDEs, preserve LF line endings.

    "},{"location":"windows/#pagination","title":"Pagination","text":"

    Pagination is disabled by default on Windows because Windows doesn't ship with a usable pager.

    If you have Git installed, you can use Git's pager and re-enable pagination:

    PS> jj config set --user ui.pager '[\"C:\\\\Program Files\\\\Git\\\\usr\\\\bin\\\\less.exe\", \"-FRX\"]'\nPS> jj config set --user ui.paginate auto\n
    "},{"location":"windows/#typing-in-powershell","title":"Typing @ in PowerShell","text":"

    PowerShell uses @ as part the array sub-expression operator, so it often needs to be escaped or quoted in commands:

    PS> jj log -r `@\nPS> jj log -r '@'\n

    One solution is to create a revset alias. For example, to make HEAD an alias for @:

    PS> jj config set --user revset-aliases.HEAD '@'\nPS> jj log -r HEAD\n
    "},{"location":"windows/#wsl-sets-the-execute-bit-on-all-files","title":"WSL sets the execute bit on all files","text":"

    When viewing a Windows drive from WSL (via /mnt/c or a similar path), Windows exposes all files with the execute bit set. Since Jujutsu automatically records changes to the working copy, this sets the execute bit on all files committed in your repository.

    If you only need to access the repository in WSL, the best solution is to clone the repository in the Linux file system (for example, in ~/my-repo).

    If you need to use the repository in both WSL and Windows, one solution is to create a workspace in the Linux file system:

    PS> jj workspace add --name wsl ~/my-repo\n

    Then only use the ~/my-repo workspace from Linux.

    "},{"location":"windows/#symbolic-link-support","title":"Symbolic link support","text":"

    jj supports symlinks on Windows only when they are enabled by the operating system. This requires Windows 10 version 14972 or higher, as well as Developer Mode. If those conditions are not satisfied, jj will materialize symlinks as ordinary files.

    For colocated repositories, Git support must also be enabled using the git config option core.symlinks=true.

    "},{"location":"working-copy/","title":"Working copy","text":""},{"location":"working-copy/#introduction","title":"Introduction","text":"

    The working copy is where the current working-copy commit's files are written so you can interact with them. It also where files are read from in order to create new commits (though there are many other ways of creating new commits).

    Unlike most other VCSs, Jujutsu will automatically create commits from the working-copy contents when they have changed. Most jj commands you run will commit the working-copy changes if they have changed. The resulting revision will replace the previous working-copy revision.

    Also unlike most other VCSs, added files are implicitly tracked. That means that if you add a new file to the working copy, it will be automatically committed once you run e.g. jj st. Similarly, if you remove a file from the working copy, it will implicitly be untracked. To untrack a file while keeping it in the working copy, first make sure it's ignored and then run jj untrack <path>.

    "},{"location":"working-copy/#conflicts","title":"Conflicts","text":"

    When you check out a commit with conflicts, those conflicts need to be represented in the working copy somehow. However, the file system doesn't understand conflicts. Jujutsu's solution is to add conflict markers to conflicted files when it writes them to the working copy. It also keeps track of the (typically 3) different parts involved in the conflict. Whenever it scans the working copy thereafter, it parses the conflict markers and recreates the conflict state from them. You can resolve conflicts by replacing the conflict markers by the resolved text. You don't need to resolve all conflicts at once. You can even resolve part of a conflict by updating the different parts of the conflict marker.

    To resolve conflicts in a commit, use jj new <commit> to create a working-copy commit on top. You would then have the same conflicts in the working-copy commit. Once you have resolved the conflicts, you can inspect the conflict resolutions with jj diff. Then run jj squash to move the conflict resolutions into the conflicted commit. Alternatively, you can edit the commit with conflicts directly in the working copy by using jj edit <commit>. The main disadvantage of that is that it's harder to inspect the conflict resolutions.

    With the jj resolve command, you can use an external merge tool to resolve conflicts that have 2 sides and a base. There is not yet a good way of resolving conflicts between directories, files, and symlinks (https://github.com/martinvonz/jj/issues/19). You can use jj restore to choose one side of the conflict, but there's no way to even see where the involved parts came from.

    "},{"location":"working-copy/#ignored-files","title":"Ignored files","text":"

    You probably don't want build outputs and temporary files to be under version control. You can tell Jujutsu to not automatically track certain files by using .gitignore files (there's no such thing as .jjignore yet). See https://git-scm.com/docs/gitignore for details about the format. .gitignore files are supported in any directory in the working copy, as well as in $HOME/.gitignore and $GIT_DIR/info/exclude.

    "},{"location":"working-copy/#workspaces","title":"Workspaces","text":"

    You can have multiple working copies backed by a single repo. Use jj workspace add to create a new working copy. The working copy will have a .jj/ directory linked to the main repo. The working copy and the .jj/ directory together is called a \"workspace\". Each workspace can have a different commit checked out.

    Having multiple workspaces can be useful for running long-running tests in a one while you continue developing in another, for example. If needed, jj workspace root prints the root path of the current workspace.

    When you're done using a workspace, use jj workspace forget to make the repo forget about it. The files can be deleted from disk separately (either before or after).

    "},{"location":"working-copy/#stale-working-copy","title":"Stale working copy","text":"

    When you modify workspace A's working-copy commit from workspace B, workspace A's working copy will become stale. By \"stale\", we mean that the files in the working copy don't match the desired commit indicated by the @ symbol in jj log. When that happens, use jj workspace update-stale to update the files in the working copy.

    "},{"location":"design/git-submodule-storage/","title":"Git submodule storage","text":""},{"location":"design/git-submodule-storage/#objective","title":"Objective","text":"

    Decide what approach(es) to Git submodule storage we should pursue. The decision will be recorded in ./git-submodules.md.

    "},{"location":"design/git-submodule-storage/#use-cases-to-consider","title":"Use cases to consider","text":"

    The submodule storage format should support the workflows specified in the submodules roadmap. It should be obvious how \"Phase 1\" requirements will be supported, and we should have an idea of how \"Phases 2,3,X\" might be supported.

    Notable use cases and workflows are noted below.

    "},{"location":"design/git-submodule-storage/#fetching-submodule-commits","title":"Fetching submodule commits","text":"

    Git's protocol is designed for communicating between copies of the same repository. Notably, a Git fetch calculates the list of required objects by performing reachability checks between the refs on the local and the remote side. We should expect that this will only work well if the submodule repository is stored as a local Git repository.

    Rolling our own Git fetch is too complex to be worth the effort.

    "},{"location":"design/git-submodule-storage/#jj-op-restore-and-operation-log-format","title":"\"jj op restore\" and operation log format","text":"

    We want jj op restore to restore to an \"expected\" state in the submodule. There is a potential distinction between running jj op restore in the superproject vs in the submodule, and the expected behavior may be different in each case, e.g. in the superproject, it might be enough to restore the submodule working copy, but in the submodule, refs also need to be restored.

    Currently, the operation log only references objects and refs in the superproject, so it is likely that proposed approaches will need to extend this format. It is also worth considering that submodules may be added, updated or removed in superproject commits, thus the list of submodules is likely to change over the repository's lifetime.

    "},{"location":"design/git-submodule-storage/#nested-submodules","title":"Nested submodules","text":"

    Git submodules may contain submodules themselves, so our chosen storage schemes should support that.

    We should consider limiting the recursion depth to avoid nasty edge cases (e.g. cyclical submodules.) that might surprise users.

    "},{"location":"design/git-submodule-storage/#supporting-future-extensions","title":"Supporting future extensions","text":"

    There are certain extensions we may want to make in the future, but we don't have a timeline for them today. Proposed approaches should take these extensions into account (e.g. the approach should be theoretically extensible), but a full proposal for implementing them is not necessary.

    These extensions are:

    • Non-git subrepos
    • Colocated Git repos
    • The superproject using a non-git backend
    "},{"location":"design/git-submodule-storage/#proposed-design","title":"Proposed design","text":"

    Git submodules will be stored as full jj repos. In the code, jj commands will only interact with the submodule's repo as an entire unit, e.g. it cannot query the submodule's commit backend directly. A well-abstracted submodule will extend well to non-git backends and non-git subrepos.

    The main challenge with this approach is that the submodule repo can be in a state that is internally valid (when considering only the submodule's repo), but invalid when considering the superproject-submodule system. This will be managed by requiring all submodule interactions go through the superproject so that superproject-submodule coordination can occur. For example, jj will not allow the user to work on the submodule's repo without going through the superproject (unlike Git).

    The notable workflows could be addressed like so:

    "},{"location":"design/git-submodule-storage/#fetching-submodule-commits_1","title":"Fetching submodule commits","text":"

    The submodule would fetch using the equivalent of jj git fetch. It remains to be decided how a \"recursive\" fetch should work, especially if a newly fetched superproject commit references an unfetched submodule commit. A reasonable approximation would be to fetch all branches in the submodule, and then, if the submodule commit is still missing, gracefully handle it.

    "},{"location":"design/git-submodule-storage/#jj-op-restore-and-operation-log-format_1","title":"\"jj op restore\" and operation log format","text":"

    As full repos, each submodule will have its own operation log. We will continue to use the existing operation log format, where each operation log tracks their own repo's commits. As commands are run in the superproject, corresponding commands will be run in the submodule as necessary, e.g. checking out a superproject commit will cause a submodule commit to also be checked out.

    Since there is no association between a superproject operation and a submodule operation, jj op restore in the superproject will not restore the submodule to a previous operation. Instead, the appropriate submodule operation(s) will be created. This is sufficient to preserve the superproject-submodule relationship; it precludes \"recursive\" restore (e.g. restoring branches in the superproject and submodules) but it seems unlikely that we will need such a thing.

    "},{"location":"design/git-submodule-storage/#nested-submodules_1","title":"Nested submodules","text":"

    Since submodules are full repos, they can contain submodules themselves. Nesting is unlikely to complicate any of the core features, since the top-level superproject/submodule relationship is almost identical to the submodule/nested submodule relationship.

    "},{"location":"design/git-submodule-storage/#extending-to-colocated-git-repos","title":"Extending to colocated Git repos","text":"

    Git expects submodules to be in .git/modules, so it will not understand this storage format. To support colocated Git repos, we will have to change Git to allow a submodule's gitdir to be in an alternate location (e.g. we could add a new submodule.<name>.gitdir config option). This is a simple change, so it should be feasible.

    "},{"location":"design/git-submodule-storage/#alternatives-considered","title":"Alternatives considered","text":""},{"location":"design/git-submodule-storage/#git-repos-in-the-main-git-backend","title":"Git repos in the main Git backend","text":"

    Since the Git backend contains a Git repository, an 'obvious' default would be to store them in the Git superproject the same way Git does, i.e. in .git/modules. Since Git submodules are full repositories that can have submodules, this storage scheme naturally extends to nested submodules.

    Most of the work in storing submodules and querying them would be well-isolated to the Git backend, which gives us a lot of flexibility to make changes without affecting the rest of jj. However, the operation log will need a significant rework since it isn't designed to reference submodules, and handling edge cases (e.g. a submodule being added/removed, nested submodules) will be tricky.

    This is rejected because handling that operation log complexity isn't worth it when very little of the work extends to non-Git backends.

    "},{"location":"design/git-submodule-storage/#store-git-submodules-as-alternate-git-backends","title":"Store Git submodules as alternate Git backends","text":"

    Teach jj to use multiple commit backends and store Git submodules as Git backends. Since submodules are separate from the 'main' backend, a repository can use whatever backend it wants as its 'main' one, while still having Git submodules in the 'alternate' Git backends.

    This approach extends fairly well to non-Git submodules (which would be stored in non-Git commit backends). However, this requires significantly reworking the operation log to account for multiple commit backends. It is also not clear how nested submodules will be supported since there isn't an obvious way to represent a nested submodule's relationship to its superproject.

    "},{"location":"design/git-submodules/","title":"Git submodules","text":"

    This is an aspirational document that describes how jj will support Git submodules. Readers are assumed to have some familiarity with Git and Git submodules.

    This document is a work in progress; submodules are a big feature, and relevant details will be filled in incrementally.

    "},{"location":"design/git-submodules/#objective","title":"Objective","text":"

    This proposal aims to replicate the workflows users are used to with Git submodules, e.g.:

    • Cloning submodules
    • Making new submodule commits and updating the superproject
    • Fetching and pushing updates to the submodule's remote
    • Viewing submodule history

    When it is convenient, this proposal will also aim to make submodules easier to use than Git's implementation.

    "},{"location":"design/git-submodules/#non-goals","title":"Non-goals","text":"
    • Non-Git 'submodules' (e.g. native jj submodules, other VCSes)
    • Non-Git backends (e.g. Google internal backend)
    • Changing how Git submodules are implemented in Git
    "},{"location":"design/git-submodules/#background","title":"Background","text":"

    We mainly want to support Git submodules for feature parity, since Git submodules are a standard feature in Git and are popular enough that we have received user requests for them. Secondarily (and distantly so), Git submodules are notoriously difficult to use, so there is an opportunity to improve the UX over Git's implementation.

    "},{"location":"design/git-submodules/#intro-to-git-submodules","title":"Intro to Git Submodules","text":"

    Git submodules are a feature of Git that allow a repository (submodule) to be embedded inside another repository (the superproject). Notably, a submodule is a full repository, complete with its own index, object store and ref store. It can be interacted with like any other repository, regardless of the superproject.

    In a superproject commit, submodule information is captured in two places:

    • A gitlink entry in the commit's tree, where the value of the gitlink entry is the submodule commit id. This tells Git what to populate in the working tree.

    • A top level .gitmodules file. This file is in Git's config syntax and entries take the form submodule.<submodule-name>.*. These include many settings about the submodules, but most importantly:

      • submodule<submodule-name>.path contains the path from the root of the tree to the gitlink being described.

      • submodule<submodule-name>.url contains the url to clone the submodule from.

    In the working tree, Git notices the presence of a submodule by the .git entry (signifying the root of a Git repository working tree). This is either the submodule's actual Git directory (an \"old-form\" submodule), or a .git file pointing to <superproject-git-directory>/modules/<submodule-name>. The latter is sometimes called the \"absorbed form\", and is Git's preferred mode of operation.

    "},{"location":"design/git-submodules/#roadmap","title":"Roadmap","text":"

    Git submodules should be implemented in an order that supports an increasing set of workflows, with the goal of getting feedback early and often. When support is incomplete, jj should not crash, but instead provide fallback behavior and warn the user where needed.

    The goal is to land good support for pure Jujutsu repositories, while colocated repositories will be supported when convenient.

    This section should be treated as a set of guidelines, not a strict order of work.

    "},{"location":"design/git-submodules/#phase-1-readonly-submodules","title":"Phase 1: Readonly submodules","text":"

    This includes work that inspects submodule contents but does not create new objects in the submodule. This requires a way to store submodules in a jj repository that supports readonly operations.

    "},{"location":"design/git-submodules/#outcomes","title":"Outcomes","text":"
    • Submodules can be cloned anew
    • New submodule commits can be fetched
    • Submodule history and branches can be viewed
    • Submodule contents are populated in the working copy
    • Superproject gitlink can be updated to an existing submodule commit
    • Conflicts in the superproject gitlink can be resolved to an existing submodule commit
    "},{"location":"design/git-submodules/#phase-2-snapshotting-new-changes","title":"Phase 2: Snapshotting new changes","text":"

    This allows a user to write new contents to a submodule and its remote.

    "},{"location":"design/git-submodules/#outcomes_1","title":"Outcomes","text":"
    • Changes in the working copy can be recorded in a submodule commit
    • Submodule branches can be modified
    • Submodules and their branches can be pushed to their remote
    "},{"location":"design/git-submodules/#phase-3-mergingrebasingconflicts","title":"Phase 3: Merging/rebasing/conflicts","text":"

    This allows merging and rebasing of superproject commits in a content-aware way (in contrast to Git, where only the gitlink commit ids are compared), as well as workflows that make resolving conflicts easy and sensible.

    This can be done in tandem with Phase 2, but will likely require a significant amount of design work on its own.

    "},{"location":"design/git-submodules/#outcomes_2","title":"Outcomes","text":"
    • Merged/rebased submodules result in merged/rebased working copy content
    • Merged/rebased working copy content can be committed, possibly by creating sensible merged/rebased submodule commits
    • Merge/rebase between submodule and non-submodule gives a sensible result
    • Merge/rebase between submodule A and submodule B gives a sensible result
    "},{"location":"design/git-submodules/#phase-an-ideal-world","title":"Phase ?: An ideal world","text":"

    I.e. outcomes we would like to see if there were no constraints whatsoever.

    • Rewriting submodule commits rewrites descendants correctly and updates superproject gitlinks.
    • Submodule conflicts automatically resolve to the 'correct' submodule commits, e.g. a merge between superproject commits creating a merge of the submodule commits.
    • Nested submodules are as easy to work with as non-nested submodules.
    • The operation log captures changes in the submodule.
    "},{"location":"design/git-submodules/#design","title":"Design","text":""},{"location":"design/git-submodules/#guiding-principles","title":"Guiding principles","text":"

    TODO

    "},{"location":"design/git-submodules/#storing-submodules","title":"Storing submodules","text":"

    Possible approaches under discussion. See ./git-submodule-storage.md.

    "},{"location":"design/git-submodules/#snapshotting-new-submodule-changes","title":"Snapshotting new submodule changes","text":"

    TODO

    "},{"location":"design/git-submodules/#mergingrebasing-with-submodules","title":"Merging/rebasing with submodules","text":"

    TODO

    "},{"location":"design/run/","title":"Introducing JJ run","text":"

    Authors: Philip Metzger, Martin von Zweigberk, Danny Hooper, Waleed Khan

    Initial Version, 10.12.2022 (view full history here)

    Summary: This Document documents the design of a new run command for Jujutsu which will be used to seamlessly integrate with build systems, linters and formatters. This is achieved by running a user-provided command or script across multiple revisions. For more details, read the Use-Cases of jj run.

    "},{"location":"design/run/#preface","title":"Preface","text":"

    The goal of this Design Document is to specify the correct behavior of jj run. The points we decide on here I (Philip Metzger) will try to implement. There exists some prior work in other DVCS:

    • git test: part of git-branchless. Similar to this proposal for jj run.
    • hg run: Google's internal Mercurial extension. Similar to this proposal for jj run. Details not available.
    • hg fix: Google's open source Mercurial extension: source code. A more specialized approach to rewriting file content without full context of the working directory.
    • git rebase -x: runs commands opportunistically as part of rebase.
    • git bisect run: run a command to determine which commit introduced a bug.
    "},{"location":"design/run/#context-and-scope","title":"Context and Scope","text":"

    The initial need for some kind of command runner integrated in the VCS, surfaced in a github discussion. In a discussion on discord about the git-hook model, there was consensus about not repeating their mistakes.

    For jj run there is prior art in Mercurial, git branchless and Google's internal Mercurial. Currently git-branchless git test and hg fix implement some kind of command runner. The Google internal hg run works in conjunction with CitC (Clients in the Cloud) which allows it to lazily apply the current command to any affected file. Currently no Jujutsu backend (Git, Native) has a fancy virtual filesystem supporting it, so we can't apply this optimization. We could do the same once we have an implementation of the working copy based on a virtual file system. Until then, we have to run the commands in regular local-disk working copies.

    "},{"location":"design/run/#goals-and-non-goals","title":"Goals and Non-Goals","text":""},{"location":"design/run/#goals","title":"Goals","text":"
    • We should be able to apply the command to any revision, published or unpublished.
    • We should be able to parallelize running the actual command, while preserving a good console output.
    • The run command should be able to work in any commit, the working-copy commit itself or any other commit.
    • There should exist some way to signal hard failure.
    • The command should build enough infrastructure for jj test, jj fix and jj format.
    • The main goal is to be good enough, as we can always expand the functionality in the future.
    "},{"location":"design/run/#non-goals","title":"Non-Goals","text":"
    • While we should build a base for jj test, jj format and jj fix, we shouldn't mash their use-cases into jj run.
    • The command shouldn't be too smart, as too many assumptions about workflows makes the command confusing for users.
    • The smart caching of outputs, as user input commands can be unpredictable. makes the command confusing for users.
    • Avoid the smart caching of outputs, as user input commands can be unpredictable.
    • Fine grained user facing configuration, as it's unwarranted complexity.
    • A fix subcommand as it cuts too much design space.
    "},{"location":"design/run/#use-cases-of-jj-run","title":"Use-Cases of jj run","text":"

    Linting and Formatting:

    • jj run 'pre-commit run' -r $revset
    • jj run 'cargo clippy' -r $revset
    • jj run 'cargo +nightly fmt'

    Large scale changes across repositories, local and remote:

    • jj run 'sed /some/test/' -r 'mine() & ~remote_branches(exact:\"origin\")'
    • jj run '$rewrite-tool' -r '$revset'

    Build systems:

    • jj run 'bazel build //some/target:somewhere'
    • jj run 'ninja check-lld'

    Some of these use-cases should get a specialized command, as this allows further optimization. A command could be jj format, which runs a list of formatters over a subset of a file in a revision. Another command could be jj fix, which runs a command like rustfmt --fix or cargo clippy --fix over a subset of a file in a revision.

    "},{"location":"design/run/#design","title":"Design","text":""},{"location":"design/run/#base-design","title":"Base Design","text":"

    All the work will be done in the .jj/ directory. This allows us to hide all complexity from the users, while preserving the user's current workspace.

    We will copy the approach from git-branchless's git test of creating a temporary working copy for each parallel command. The working copies will be reused between jj run invocations. They will also be reused within jj run invocation if there are more commits to run on than there are parallel jobs.

    We will leave ignored files in the temporary directory between runs. That enables incremental builds (e.g by letting cargo reuse its target/ directory). However, it also means that runs potentially become less reproducible. We will provide a flag for removing ignored files from the temporary working copies to address that.

    Another problem with leaving ignored files in the temporary directories is that they take up space. That is especially problematic in the case of cargo (the target/ directory often takes up tens of GBs). The same flag for cleaning up ignored files can be used to address that. We may want to also have a flag for cleaning up temporary working copies after running the command.

    An early version of the command will directly use Treestate to to manage the temporary working copies. That means that running jj inside the temporary working copies will not work . We can later extend that to use a full Workspace. To prevent operations in the working copies from impacting the repo, we can use a separate OpHeadsStore for it.

    "},{"location":"design/run/#modifying-the-working-copy","title":"Modifying the Working Copy","text":"

    Since the subprocesses will run in temporary working copies, they won't interfere with the user's working copy. The user can therefore continue to work in it while jj run is running.

    We want subprocesses to be able to make changes to the repo by updating their assigned working copy. Let's say the user runs jj run on just commits A and B, where B's parent is A. Any changes made on top of A would be squashed into A, forming A'. Similarly B' would be formed by squasing it into B. We can then either do a normal rebase of B' onto A', or we can simply update its parent to A'. The former is useful, e.g when the subprocess only makes a partial update of the tree based on the parent commit. In addition to these two modes, we may want to have an option to ignore any changes made in the subprocess's working copy.

    "},{"location":"design/run/#modifying-the-repo","title":"Modifying the Repo","text":"

    Once we give the subprocess access to a fork of the repo via separate OpHeadsStore, it will be able to create new operations in its fork. If the user runs jj run -r foo and the subprocess checks out another commit, it's not clear what that should do. We should probably just verify that the working-copy commit's parents are unchanged after the subprocess returns. Any operations created by the subprocess will be ignored.

    "},{"location":"design/run/#rewriting-the-revisions","title":"Rewriting the revisions","text":"

    Like all commands, jj run will refuse to rewrite public/immutable commits. For private/unpublished revisions, we either amend or reparent the changes, which are available as command options.

    "},{"location":"design/run/#execution-orderparallelism","title":"Execution order/parallelism","text":"

    It may be useful to execute commands in topological order. For example, commands with costs proportional to incremental changes, like build systems. There may also be other revelant heuristics, but topological order is an easy and effective way to start.

    Parallel execution of commands on different commits may choose to schedule commits to still reduce incremental changes in the working copy used by each execution slot/\"thread\". However, running the command on all commits concurrently should be possible if desired.

    Executing commands in topological order allows for more meaningful use of any potential features that stop execution \"at the first failure\". For example, when running tests on a chain of commits, it might be useful to proceed in topological/chronological order, and stop on the first failure, because it might imply that the remaining executions will be undesirable because they will also fail.

    "},{"location":"design/run/#dealing-with-failure","title":"Dealing with failure","text":"

    It will be useful to have multiple strategies to deal with failures on a single or multiple revisions. The reason for these strategies is to allow customized conflict handling. These strategies then can be exposed in the ui with a matching option.

    Continue: If any subprocess fails, we will continue the work on child revisions. Notify the user on exit about the failed revisions.

    Stop: Signal a fatal failure and cancel any scheduled work that has not yet started running, but let any already started subprocess finish. Notify the user about the failed command and display the generated error from the subprocess.

    Fatal: Signal a fatal failure and immediately stop processing and kill any running processes. Notify the user that we failed to apply the command to the specific revision.

    We will leave any affected commit in its current state, if any subprocess fails. This allows us provide a better user experience, as leaving revisions in an undesirable state, e.g partially formatted, may confuse users.

    "},{"location":"design/run/#resource-constraints","title":"Resource constraints","text":"

    It will be useful to constrain the execution to prevent resource exhaustion. Relevant resources could include:

    • CPU and memory available on the machine running the commands. jj run can provide some simple mitigations like limiting parallelism to \"number of CPUs\" by default, and limiting parallelism by dividing \"available memory\" by some estimate or measurement of per-invocation memory use of the commands.
    • External resources that are not immediately known to jj. For example, commands run in parallel may wish to limit the total number of connections to a server. We might choose to defer any handling of this to the implementation of the command being invoked, instead of trying to communicate that information to jj.
    "},{"location":"design/run/#command-options","title":"Command Options","text":"

    The base command of any jj command should be usable. By default jj run works on the @ the current working copy.

    • --command, explicit name of the first argument
    • -x, for git compatibility (may alias another command)
    • -j, --jobs, the amount of parallelism to use
    • -k, --keep-going, continue on failure (may alias another command)
    • --show, display the diff for an affected revision
    • --dry-run, do the command execution without doing any work, logging all intended files and arguments
    • --rebase, rebase all parents on the consulitng diff (may alias another command)
    • --reparent, change the parent of an effected revision to the new change (may alias another command)
    • --clean, remove existing workspaces and remove the ignored files
    • --readonly, ignore changes across multiple run invocations
    • --error-strategy=continue|stop|fatal, see Dealing with failure
    "},{"location":"design/run/#integrating-with-other-commands","title":"Integrating with other commands","text":"

    jj log: No special handling needed jj diff: No special handling needed jj st: For now reprint the final output of jj run jj op log: No special handling needed, but awaits further discussion in #963 jj undo/jj op undo: No special handling needed

    "},{"location":"design/run/#open-points","title":"Open Points","text":"

    Should the command be working copy backend specific? How do we manage the Processes which the command will spawn? Configuration options, User and Repository Wide?

    "},{"location":"design/run/#future-possibilities","title":"Future possibilities","text":"
    • We could rewrite the file in memory, which is a neat optimization
    • Exposing some internal state, to allow preciser resource constraints
    • Integration options for virtual filesystems, which allow them to cache the needed working copies.
    • A Jujutsu wide concept for a cached working copy, as they could be expensive to materialize.
    • Customized failure messages, this maybe useful for bots, it could be similar to Bazel's select(..., message = \"arch not supported for $project\").
    • Make jj run asynchronous by spawning a main process, directly return to the user and incrementally updating the output of jj st.
    "},{"location":"design/sparse-v2/","title":"Sparse Patterns v2 redesign","text":"

    Authors: Daniel Ploch

    Summary: This Document documents a redesign of the sparse command and it's internal storage format in jj, in order to facilitate several desirable improvements for large repos. It covers both the migration path and the planned end state.

    "},{"location":"design/sparse-v2/#objective","title":"Objective","text":"

    Redesign Sparse Patterns to accommodate more advanced features for native and custom implementations. This includes three main goals:

    1. Sparse Patterns should be versioned with the working copy
    2. Sparse Patterns should support more flexible matching rules
    3. Sparse Patterns should support client path remapping
    "},{"location":"design/sparse-v2/#current-state-as-of-jj-0130","title":"Current State (as of jj 0.13.0)","text":"

    Sparse patterns are an effectively unordered list of prefix strings:

    path/one\npath/to/dir/two\n

    The set of files identified by the Sparse Patterns is all paths which match any provided prefix. This governs what gets materialized in the working copy on checkout, and what is updated on snapshot. The set is stored in working copy state files which are not versioned in the Op Store.

    Because all paths are bare strings with no escaping or higher-level formatting, the current design makes it difficult to add new features like exclusions or path remappings.

    "},{"location":"design/sparse-v2/#proposed-state-sparse-patterns-v2","title":"Proposed State (Sparse Patterns v2)","text":"

    Sparse Patterns v2 will be stored as objects in the Op Store, referenced by a WorkingCopyPatternsId from the active View. They will have a new, ordered structure which can fully represent previous patterns.

    /// Analogues of RepoPath, specifically describing paths in the working copy.\nstruct WorkingCopyPathBuf {\n    String\n}\nstruct WorkingCopyPath {\n    str\n}\n\npub enum SparsePatternsPathType {\n    Dir,    // Everything under <path>/...\n    Files,  // Files under <path>/*\n    Exact,  // <path> exactly\n}\n\npub struct SparsePatternsPath {\n    path_type: SparsePatternsPathType,\n    include: bool,  // True if included, false if excluded.\n    path: RepoPathBuf,\n}\n\npub struct WorkingCopyMapping {\n    src_path: RepoPathBuf,\n    dst_path: WorkingCopyPathBuf,\n    recursive: bool,  // If false, only immediate children of src_path (files) are renamed.\n}\n\npub struct WorkingCopyPatterns {\n    sparse_paths: Vec<SparsePatternsPath>,\n    mappings: Vec<WorkingCopyMapping>,\n}\n\npub trait OpStore {\n    ...\n    pub fn read_working_copy_patterns(&self, id: &WorkingCopyPatternsId) -> OpStoreResult<WorkingCopyPatterns> { ... }\n    pub fn write_working_copy_patterns(&self, sparse_patterns: &WorkingCopyPatterns) -> OpStoreResult<WorkingCopyPatternsId> { .. }\n}\n

    To support these more complex behaviors, a new WorkingCopyPatterns trait will be introduced, initially only as a thin wrapper around the existing prefix format, but soon to be expanded with richer types and functionality.

    impl WorkingCopyPatterns {\n    pub fn to_matcher(&self) -> Box<dyn Matcher> {\n        ...\n    }\n\n    ...\n}\n
    "},{"location":"design/sparse-v2/#command-syntax","title":"Command Syntax","text":"

    SparsePatternsPath rules can be specified on the CLI and in an editor via a compact syntax:

    (include|exclude):(dir|files|exact):<path>\n

    If both prefix terms are omitted, then include:dir: is assumed. If any prefix is specified, both must be specified. The editor and CLI will both accept path rules in either format going forward.

    • jj sparse set --add foo/bar is equal to jj sparse set --add include:dir:foo/bar
    • jj sparse set --add exclude:dir:foo/bar adds a new Dir type rule with include = false
    • jj sparse set --exclude foo/bar as a possible shorthand for the above
    • jj sparse list will print the explicit rules

    Paths will be stored in an ordered, canonical form which unambiguously describes the set of files to be included. Every --add command will append to the end of this list before the patterns are canonicalized. Whether a file is included is determined by the first matching rule in reverse order.

    For example:

    include:dir:foo\nexclude:dir:foo/bar\ninclude:dir:foo/bar/baz\nexclude:dir:foo/bar/baz/qux\n

    Produces rule set which includes \"foo/file.txt\", excludes \"foo/bar/file.txt\", includes \"foo/bar/baz/file.txt\", and excludes \"foo/bar/baz/qux/file.txt\".

    If the rules are subtly re-ordered, they become canonicalized to a smaller, but functionally equivalent form:

    # Before\ninclude:dir:foo\nexclude:dir:foo/bar/baz/qux\ninclude:dir:foo/bar/baz\nexclude:dir:foo/bar\n\n# Canonicalized\ninclude:dir:foo\nexclude:dir:foo/bar\n
    "},{"location":"design/sparse-v2/#canonicalization","title":"Canonicalization","text":"

    There are many ways to represent functionally equivalent WorkingCopyPatterns. For instance, the following 4 rule sets are all functionally equivalent:

    # Set 1\ninclude:dir:bar\ninclude:dir:foo\n\n# Set 2\ninclude:dir:foo\ninclude:dir:bar\n\n# Set 3\ninclude:dir:bar\ninclude:dir:bar/baz/qux\ninclude:dir:foo\n\n# Set 4\ninclude:dir:foo\nexclude:dir:foo/baz\ninclude:dir:bar\ninclude:dir:foo/baz\n

    Because these patterns are stored in the Op Store now, it is useful for all of these representations to be rewritten into a minimal, canonical form before serialization. In this case, Set 1 will be the canonical set. The canonical form of a WorkingCopyPatterns is defined as the form such that:

    • Every rule affects the functionality (there are no redundant rules)
    • Rules are sorted lexicographically, but with '/' sorted before all else
      • This special sorting order is useful for constructing path tries
    "},{"location":"design/sparse-v2/#working-copy-map","title":"Working Copy Map","text":"

    WARNING: This section is intentionally lacking, more research is needed.

    All WorkingCopyPatterns will come equipped with a default no-op mapping. These mappings are inspired by and similar to Perforce client views.

    vec![WorkingCopyMapping {\n    src_path: RepoPathBuf::root(),\n    dst_path: WorkingCopyPathBuf::root(),\n    recursive: true,\n}]\n

    WorkingCopyPatterns will provide an interface to map working copy paths into repo paths and vice versa. The `WorkingCopy`` trait will apply this mapping to all snapshot and checkout operations, and jj commands which accept relative paths will need to be updated to perform working copy path -> repo path translations as needed. It's not clear at this time which commands will need changing, as some are more likely to refer to repo paths rather than working copy paths.

    TODO: Expand this section.

    In particular, the path rules for sparse patterns will always be repo paths, not working copy paths. Thus, if the working copy wants to track \"foo\" and rename it to \"subdir/bar\", they must jj sparse set --add foo and jj map set --from foo --to bar. In other words, the mapping operation can be thought of as always after the sparse operation.

    "},{"location":"design/sparse-v2/#command-syntax_1","title":"Command Syntax","text":"

    New commands will enable editing of the WorkingCopyMappings:

    TODO: Maybe this should be jj workspace map ...?

    • jj map list will print all mapping pairs.
    • jj map add --from foo --to bar will add a new mapping to the end of the list.
    • jj map remove --from foo will remove a specific mapping rule.
    • jj map edit will pull up a text editor for manual editing.

    Like sparse paths, mappings will have a compact text syntax for editing in file form, or for adding a rule textually on the CLI:

    \"<from>\" -> \"<to>\" [nonrecursive]\n

    Like sparse paths, mapping rules are defined to apply in order and on any save operation will be modified to a minimal canonical form. Thus, jj map set --from \"\" --to \"\" will always completely wipe the map. The first matching rule in reverse list order determines how a particular repo path should be mapped into the working copy, and likewise how a particular working copy path should be mapped into the repo. For simplicity, the 'last rule wins' applies both for repo->WC conversions, as well as WC->repo conversions, using the same ordering.

    If a working copy mapping places the same repo file at two distinct working copy paths, snapshotting will fail unless these files are identical. Some specialized filesystems may even treat these as the 'same' file, allowing this to work in some cases.

    If a working copy mapping places two distinct repo files at the same working copy path, checkout will fail with an error regardless of equivalence.

    "},{"location":"design/sparse-v2/#versioning-and-storage","title":"Versioning and Storage","text":"

    Updating the active WorkingCopyPatterns for a particular working copy will now take place in two separate steps: one transaction which updates the op store, and a separate LockedWorkingCopy operation which actually updates the working copy. The working copy proto will no longer store WorkingCopyPatterns directly, instead storing only a WorkingCopyPatternsId. On mismatch with the current op head, the user will be prompted to run jj workspace update-stale.

    This gives the user the ability to update the active WorkingCopyPatterns whilst not interacting with the local working copy, which is useful for custom integrations which may not be able to check out particular working copy patterns due to problems with the backend (encoding, permission errors, etc.). A bad jj sparse set --add oops command can thus be undone, even via jj op undo if desired.

    "},{"location":"design/sparse-v2/#view-updates","title":"View Updates","text":"

    The View object will be migrated to store working copy patterns via id. The indirection will save on storage since working copy patterns are not expected to change very frequently.

    // Before:\npub wc_commit_ids: HashMap<WorkspaceId, CommitId>,\n\n// After:\npub struct WorkingCopyInfo {\n    pub commit_id: CommitId,\n    pub wc_patterns_id: WorkingCopyPatternsId,\n}\n...\npub wc_info: HashMap<WorkspaceId, WorkingCopyInfo>,\n

    A View object with no stored working copy patterns will be modified at read time to include the current working copy patterns, thus all read_view operations will need to pass in the current working copy patterns for a migration period of at least 6 months. After that, we may choose to auto-fill missing working copy infos with a default WorkingCopyPatterns as needed.

    "},{"location":"design/sparse-v2/#appendix","title":"Appendix","text":""},{"location":"design/sparse-v2/#related-work","title":"Related Work","text":"

    Perforce client maps are very similar in concept to the entirety of WorkingCopyPatterns, and this design aims to achieve similar functionality.

    The Josh Project implements partial git clones in a way similar to how sparse patterns try to work.

    "},{"location":"design/sparse-v2/#patterns-via-configuration","title":"Patterns via configuration","text":"

    There may be some scenarios where it is valuable to configure working copy patterns via a configuration file, rather than through explicit commands. Generally this only makes sense for automated repos, with the configuration coming from outside the repo - there are too many caveats and edge cases if the configuration comes from inside the repo and/or is fought with by a human.

    No configuration syntax is planned at this time but if we add any, we should probably reuse the compact line syntaxes as much as possible for consistency.

    "},{"location":"design/tracking-branches/","title":"Remote/@git tracking branches","text":"

    This is a plan to implement more Git-like remote tracking branch UX.

    "},{"location":"design/tracking-branches/#objective","title":"Objective","text":"

    jj imports all remote branches to local branches by default. As described in #1136, this doesn't interact nicely with Git if we have multiple Git remotes with a number of branches. The git.auto-local-branch config can mitigate this problem, but we'll get locally-deleted branches instead.

    The goal of this plan is to implement

    • proper support for tracking/non-tracking remote branches
    • logically consistent data model for importing/exporting Git refs
    "},{"location":"design/tracking-branches/#current-data-model-as-of-jj-080","title":"Current data model (as of jj 0.8.0)","text":"

    Under the current model, all remote branches are \"tracking\" branches, and remote changes are merged into the local counterparts.

    branches\n  [name]:\n    local_target?\n    remote_targets[remote]: target\ntags\n  [name]: target\ngit_refs\n  [\"refs/heads/{name}\"]: target             # last-known local branches\n  [\"refs/remotes/{remote}/{name}\"]: target  # last-known remote branches\n                                            # (copied to remote_targets)\n  [\"refs/tags/{name}\"]: target              # last-known tags\ngit_head: target?\n
    • Remote branches are stored in both branches[name].remote_targets and git_refs[\"refs/remotes\"]. These two are mostly kept in sync, but there are two scenarios where remote-tracking branches and git refs can diverge:
      1. jj branch forget
      2. jj op undo/restore in colocated repo
    • Pseudo @git tracking branches are stored in git_refs[\"refs/heads\"]. We need special case to resolve @git branches, and their behavior is slightly different from the other remote-tracking branches.
    "},{"location":"design/tracking-branches/#proposed-data-model","title":"Proposed data model","text":"

    We'll add a per-remote-branch state to distinguish non-tracking branches from tracking ones.

    state = new        # not merged in the local branch or tag\n      | tracking   # merged in the local branch or tag\n# `ignored` state could be added if we want to manage it by view, not by\n# config file. target of ignored remote branch would be absent.\n

    We'll add a per-remote view-like object to record the last known remote branches. It will replace branches[name].remote_targets in the current model. @git branches will be stored in remotes[\"git\"].

    branches\n  [name]: target\ntags\n  [name]: target\nremotes\n  [\"git\"]:\n    branches\n      [name]: target, state                 # refs/heads/{name}\n    tags\n      [name]: target, state = tracking      # refs/tags/{name}\n    head: target?, state = TBD              # refs/HEAD\n  [remote]:\n    branches\n      [name]: target, state                 # refs/remotes/{remote}/{name}\n    tags: (empty)\n    head: (empty)\ngit_refs                                    # last imported/exported refs\n  [\"refs/heads/{name}\"]: target\n  [\"refs/remotes/{remote}/{name}\"]: target\n  [\"refs/tags/{name}\"]: target\n

    With the proposed data model, we can

    • naturally support remote branches which have no local counterparts
    • deduplicate branches[name].remote_targets and git_refs[\"refs/remotes\"]
    "},{"location":"design/tracking-branches/#importexport-data-flow","title":"Import/export data flow","text":"
           export flow                              import flow\n       -----------                              -----------\n                        +----------------+                   --.\n   +------------------->|backing Git repo|---+                 :\n   |                    +----------------+   |                 : unchanged\n   |[update]                                 |[copy]           : on \"op restore\"\n   |                      +----------+       |                 :\n   |      +-------------->| git_refs |<------+                 :\n   |      |               +----------+       |               --'\n   +--[compare]                            [diff]--+\n          |   .--       +---------------+    |     |         --.\n          |   :    +--->|remotes[\"git\"] |    |     |           :\n          +---:    |    |               |<---+     |           :\n              :    |    |remotes[remote]|          |           : restored\n              '--  |    +---------------+          |[merge]    : on \"op restore\"\n                   |                               |           : by default\n             [copy]|    +---------------+          |           :\n                   +----| (local)       |<---------+           :\n                        | branches/tags |                      :\n                        +---------------+                    --'\n
    • jj git import applies diff between git_refs and remotes[]. git_refs is always copied from the backing Git repo.
    • jj git export copies jj's remotes view back to the Git repo. If a ref in the Git repo has been updated since the last import, the ref isn't exported.
    • jj op restore never rolls back git_refs.
    "},{"location":"design/tracking-branches/#tracking-state","title":"Tracking state","text":"

    The git.auto-local-branch config knob is applied when importing new remote branch. jj branch sub commands will be added to change the tracking state.

    fn default_state_for_newly_imported_branch(config, remote) {\n    if remote == \"git\" {\n        State::Tracking\n    } else if config[\"git.auto-local-branch\"] {\n        State::Tracking\n    } else {\n        State::New\n    }\n}\n

    A branch target to be merged is calculated based on the state.

    fn target_in_merge_context(known_target, state) {\n    match state {\n        State::New => RefTarget::absent(),\n        State::Tracking => known_target,\n    }\n}\n
    "},{"location":"design/tracking-branches/#mapping-to-the-current-data-model","title":"Mapping to the current data model","text":"
    • New remotes[\"git\"].branches corresponds to git_refs[\"refs/heads\"], but forgotten branches are removed from remotes[\"git\"].branches.
    • New remotes[\"git\"].tags corresponds to git_refs[\"refs/tags\"].
    • New remotes[\"git\"].head corresponds to git_head.
    • New remotes[remote].branches corresponds to branches[].remote_targets[remote].
    • state = new|tracking doesn't exist in the current model. It's determined by git.auto-local-branch config.
    "},{"location":"design/tracking-branches/#common-command-behaviors","title":"Common command behaviors","text":"

    In the following sections, a merge is expressed as adds - removes. In particular, a merge of local and remote targets is [local, remote] - [known_remote].

    "},{"location":"design/tracking-branches/#fetchimport","title":"fetch/import","text":"
    • jj git fetch

      1. Fetches remote changes to the backing Git repo.
      2. Import changes only for remotes[remote].branches[glob] (see below)
        • TODO: how about fetched .tags?
    • jj git import

      1. Copies git_refs from the backing Git repo.
      2. Calculates diff from the known remotes to the new git_refs.
        • git_refs[\"refs/heads\"] - remotes[\"git\"].branches
        • git_refs[\"refs/tags\"] - remotes[\"git\"].tags
        • TBD: \"HEAD\" - remotes[\"git\"].head (unused)
        • git_refs[\"refs/remotes/{remote}\"] - remotes[remote]
      3. Merges diff in local branches and tags if state is tracking.
        • If the known target is absent, the default state should be calculated. This also applies to previously-forgotten branches.
      4. Updates remotes reflecting the import.
      5. Abandons commits that are no longer referenced.
    "},{"location":"design/tracking-branches/#pushexport","title":"push/export","text":"
    • jj git push

      1. Calculates diff from the known remotes[remote] to the local changes.
        • branches - remotes[remote].branches
          • If state is new (i.e. untracked), the known remote branch target is considered absent.
          • If state is new, and if the local branch target is absent, the diff [absent, remote] - absent is noop. So it's not allowed to push deleted branch to untracked remote.
          • TODO: Copy Git's --force-with-lease behavior?
        • ~tags~ (not implemented, but should be the same as branches)
      2. Pushes diff to the remote Git repo (as well as remote tracking branches in the backing Git repo.)
      3. Updates remotes[remote] and git_refs reflecting the push.
    • jj git export

      1. Copies local branches/tags back to remotes[\"git\"].
        • Conceptually, remotes[\"git\"].branches[name].state can be set to untracked. Untracked local branches won't be exported to Git.
        • If remotes[\"git\"].branches[name] is absent, the default state = tracking applies. This also applies to forgotten branches.
        • ~tags~ (not implemented, but should be the same as branches)
      2. Calculates diff from the known git_refs to the new remotes[remote].
      3. Applies diff to the backing Git repo.
      4. Updates git_refs reflecting the export.

      If a ref failed to export at the step 3, the preceding steps should also be rolled back for that ref.

    "},{"location":"design/tracking-branches/#initclone","title":"init/clone","text":"
    • jj init

      • Import, track, and merge per git.auto_local_branch config.
      • If !git.auto_local_branch, no tracking state will be set.
    • jj git clone

      • Import, track, and merge per git.auto_local_branch config.
      • The default branch will be tracked regardless of git.auto_local_branch config. This isn't technically needed, but will help users coming from Git.
    "},{"location":"design/tracking-branches/#branch","title":"branch","text":"
    • jj branch set {name}
      1. Sets local branches[name] entry.
    • jj branch delete {name}
      1. Removes local branches[name] entry.
    • jj branch forget {name}
      1. Removes local branches[name] entry if exists.
      2. Removes remotes[remote].branches[name] entries if exist. TODO: maybe better to not remove non-tracking remote branches?
    • jj branch track {name}@{remote} (new command)
      1. Merges [local, remote] - [absent] in local branch.
        • Same as \"fetching/importing existing branch from untracked remote\".
      2. Sets remotes[remote].branches[name].state = tracking.
    • jj branch untrack {name}@{remote} (new command)
      1. Sets remotes[remote].branches[name].state = new.
    • jj branch list
      • TODO: hide non-tracking branches by default? ...

    Note: desired behavior of jj branch forget is to

    • discard both local and remote branches (without actually removing branches at remotes)
    • not abandon commits which belongs to those branches (even if the branch is removed at a remote)
    "},{"location":"design/tracking-branches/#command-behavior-examples","title":"Command behavior examples","text":""},{"location":"design/tracking-branches/#fetchimport_1","title":"fetch/import","text":"
    • Fetching/importing new branch
      1. Decides new state = new|tracking based on git.auto_local_branch
      2. If new state is tracking, merges [absent, new_remote] - [absent] (i.e. creates local branch with new_remote target)
      3. Sets remotes[remote].branches[name].state
    • Fetching/importing existing branch from tracking remote
      1. Merges [local, new_remote] - [known_remote]
    • Fetching/importing existing branch from untracked remote
      1. Decides new state = new|tracking based on git.auto_local_branch
      2. If new state is tracking, merges [local, new_remote] - [absent]
      3. Sets remotes[remote].branches[name].state
    • Fetching/importing remotely-deleted branch from tracking remote
      1. Merges [local, absent] - [known_remote]
      2. Removes remotes[remote].branches[name] (target becomes absent) (i.e. the remote branch is no longer tracked)
      3. Abandons commits in the deleted branch
    • Fetching/importing remotely-deleted branch from untracked remote
      1. Decides new state = new|tracking based on git.auto_local_branch
      2. Noop anyway since [local, absent] - [absent] -> local
    • Fetching previously-forgotten branch from remote
      1. Decides new state = new|tracking based on git.auto_local_branch
      2. If new state is tracking, merges [absent, new_remote] - [absent] -> new_remote
      3. Sets remotes[remote].branches[name].state
    • Fetching forgotten and remotely-deleted branch
      • Same as \"remotely-deleted branch from untracked remote\" since forgotten remote branch should be state = new
      • Therefore, no local commits should be abandoned
    "},{"location":"design/tracking-branches/#push","title":"push","text":"
    • Pushing new branch, remote doesn't exist
      1. Pushes [local, absent] - [absent] -> local
      2. Sets remotes[remote].branches[name].target = local, .state = tracking
    • Pushing new branch, untracked remote exists
      1. Pushes [local, remote] - [absent]
        • Fails if local moved backwards or sideways
      2. Sets remotes[remote].branches[name].target = local, .state = tracking
    • Pushing existing branch to tracking remote
      1. Pushes [local, remote] - [remote] -> local
        • Fails if local moved backwards or sideways, and if remote is out of sync
      2. Sets remotes[remote].branches[name].target = local
    • Pushing existing branch to untracked remote
      • Same as \"new branch\"
    • Pushing deleted branch to tracking remote
      1. Pushes [absent, remote] - [remote] -> absent
        • TODO: Fails if remote is out of sync?
      2. Removes remotes[remote].branches[name] (target becomes absent)
    • Pushing deleted branch to untracked remote
      • Noop since [absent, remote] - [absent] -> remote
      • Perhaps, UI will report error
    • Pushing forgotten branch to untracked remote
      • Same as \"deleted branch to untracked remote\"
    • Pushing previously-forgotten branch to remote
      • Same as \"new branch, untracked remote exists\"
      • The target of forgotten remote branch is absent
    "},{"location":"design/tracking-branches/#export","title":"export","text":"
    • Exporting new local branch, git branch doesn't exist
      1. Sets remotes[\"git\"].branches[name].target = local, .state = tracking
      2. Exports [local, absent] - [absent] -> local
    • Exporting new local branch, git branch is out of sync
      1. Exports [local, git] - [absent] -> fail
    • Exporting existing local branch, git branch is synced
      1. Sets remotes[\"git\"].branches[name].target = local
      2. Exports [local, git] - [git] -> local
    • Exporting deleted local branch, git branch is synced
      1. Removes remotes[\"git\"].branches[name]
      2. Exports [absent, git] - [git] -> absent
    • Exporting forgotten branches, git branches are synced
      1. Exports [absent, git] - [git] -> absent for forgotten local/remote branches
    "},{"location":"design/tracking-branches/#undo-fetch","title":"undo fetch","text":"
    • Exporting undone fetch, git branches are synced
      1. Exports [old, git] - [git] -> old for undone local/remote branches
    • Redoing undone fetch without exporting
      • Same as plain fetch since the known git_refs isn't diffed against the refs in the backing Git repo.
    "},{"location":"design/tracking-branches/#git-remote","title":"@git remote","text":"
    • jj branch untrack {name}@git
      • Maybe rejected (to avoid confusion)?
      • Allowing this would mean different local branches of the same name coexist in jj and git.
    • jj git fetch --remote git
      • Rejected. The implementation is different.
      • Conceptually, it's git::import_refs() only for local branches.
    • jj git push --remote git
      • Rejected. The implementation is different.
      • Conceptually, it's jj branch track and git::export_refs() only for local branches.
    "},{"location":"design/tracking-branches/#remaining-issues","title":"Remaining issues","text":"
    • https://github.com/martinvonz/jj/issues/1278 pushing to tracked remote
      • Option could be added to push to all tracking remotes?
    • Track remote branch locally with different name
      • Local branch name could be stored per remote branch
      • Consider UI complexity
    • \"private\" state (suggested by @ilyagr)
      • \"private\" branches can be pushed to their own remote, but not to the upstream repo
      • This might be a state attached to a local branch (similar to Mercurial's \"secret\" phase)
    "},{"location":"design/tracking-branches/#references","title":"References","text":"
    • https://github.com/martinvonz/jj/issues/1136
    • https://github.com/martinvonz/jj/issues/1666
    • https://github.com/martinvonz/jj/issues/1690
    • https://github.com/martinvonz/jj/issues/1734
    • https://github.com/martinvonz/jj/pull/1739
    "},{"location":"technical/architecture/","title":"Architecture","text":""},{"location":"technical/architecture/#data-model","title":"Data model","text":"

    The commit data model is similar to Git's object model , but with some differences.

    "},{"location":"technical/architecture/#separation-of-library-from-ui","title":"Separation of library from UI","text":"

    The jj binary consists of two Rust crates: the library crate (jj-lib) and the CLI crate (jj-cli). The library crate is currently only used by the CLI crate, but it is meant to also be usable from a GUI or TUI, or in a server serving requests from multiple users. As a result, the library should avoid interacting directly with the user via the terminal or by other means; all input/output is handled by the CLI crate 1. Since the library crate is meant to usable in a server, it also cannot read configuration from the user's home directory, or from user-specific environment variables.

    A lot of thought has gone into making the library crate's API easy to use, but not much has gone into \"details\" such as which collection types are used, or which symbols are exposed in the API.

    "},{"location":"technical/architecture/#storage-independent-apis","title":"Storage-independent APIs","text":"

    One overarching principle in the design is that it should be easy to change where data is stored. The goal was to be able to put storage on local-disk by default but also be able to move storage to the cloud at Google (and for anyone). To that end, commits (and trees, files, etc.) are stored by the commit backend, operations (and views) are stored by the operation backend, the heads of the operation log are stored by the \"op heads\" backend, the commit index is stored by the index backend, and the working copy is stored by the working copy backend. The interfaces are defined in terms of plain Rust data types, not tied to a specific format. The working copy doesn't have its own trait defined yet, but its interface is small and easy to create traits for when needed.

    The commit backend to use when loading a repo is specified in the .jj/repo/store/type file. There are similar files for the other backends (.jj/repo/index/type, .jj/repo/op_store/type, .jj/repo/op_heads/type).

    "},{"location":"technical/architecture/#design-of-the-library-crate","title":"Design of the library crate","text":""},{"location":"technical/architecture/#overview","title":"Overview","text":"

    Here's a diagram showing some important types in the library crate. The following sections describe each component.

    graph TD;\n    ReadonlyRepo-->Store;\n    ReadonlyRepo-->OpStore;\n    ReadonlyRepo-->OpHeadsStore;\n    ReadonlyRepo-->ReadonlyIndex\n    MutableIndex-->ReadonlyIndex;\n    Store-->Backend;\n    GitBackend-->Backend;\n    LocalBackend-->Backend;\n    LocalBackend-->StackedTable;\n    MutableRepo-->ReadonlyRepo;\n    MutableRepo-->MutableIndex;\n    Transaction-->MutableRepo;\n    WorkingCopy-->TreeState;\n    Workspace-->WorkingCopy;\n    Workspace-->RepoLoader;\n    RepoLoader-->Store;\n    RepoLoader-->OpStore;\n    RepoLoader-->OpHeadsStore;\n    RepoLoader-->ReadonlyRepo;\n    Git-->GitBackend;\n    GitBackend-->StackedTable;
    "},{"location":"technical/architecture/#backend","title":"Backend","text":"

    The Backend trait defines the interface each commit backend needs to implement. The current in-tree commit backends are GitBackend and LocalBackend.

    Since there are non-commit backends, the Backend trait should probably be renamed to CommitBackend.

    "},{"location":"technical/architecture/#gitbackend","title":"GitBackend","text":"

    The GitBackend stores commits in a Git repository. It uses libgit2 to read and write commits and refs.

    To prevent GC from deleting commits that are still reachable from the operation log, the GitBackend stores a ref for each commit in the operation log in the refs/jj/keep/ namespace.

    Commit data that is available in Jujutsu's model but not in Git's model is stored in a StackedTable in .jj/repo/store/extra/. That is currently the change ID and the list of predecessors. For commits that don't have any data in that table, which is any commit created by git, we use an empty list as predecessors, and the bit-reversed commit ID as change ID.

    Because we use the Git Object ID as commit ID, two commits that differ only in their change ID, for example, will get the same commit ID, so we error out when trying to write the second one of them.

    "},{"location":"technical/architecture/#localbackend","title":"LocalBackend","text":"

    The LocalBackend is just a proof of concept. It stores objects addressed by their hash, with one file per object.

    "},{"location":"technical/architecture/#store","title":"Store","text":"

    The Store type wraps the Backend and returns wrapped types for commits and trees to make them easier to use. The wrapped objects have a reference to the Store itself, so you can do e.g. commit.parents() without having to provide the Store as an argument.

    The Store type also provides caching of commits and trees.

    "},{"location":"technical/architecture/#readonlyrepo","title":"ReadonlyRepo","text":"

    A ReadonlyRepo represents the state of a repo at a specific operation. It keeps the view object associated with that operation.

    The repository doesn't know where on disk any working copies live. It knows, via the view object, which commit is supposed to be the current working-copy commit in each workspace.

    "},{"location":"technical/architecture/#mutablerepo","title":"MutableRepo","text":"

    A MutableRepo is a mutable version of ReadonlyRepo. It has a reference to its base ReadonlyRepo, but it has its own copy of the view object and lets the caller modify it.

    "},{"location":"technical/architecture/#transaction","title":"Transaction","text":"

    The Transaction object has a MutableRepo and metadata that will go into the operation log. When the transaction commits, the MutableRepo becomes a view object in the operation log on disk, and the Transaction object becomes an operation object. In memory, Transaction::commit() returns a new ReadonlyRepo.

    "},{"location":"technical/architecture/#repoloader","title":"RepoLoader","text":"

    The RepoLoader represents a repository at an unspecified operation. You can think of as a pointer to the .jj/repo/ directory. It can create a ReadonlyRepo given an operation ID.

    "},{"location":"technical/architecture/#treestate","title":"TreeState","text":"

    The TreeState type represents the state of the files in a working copy. It keep track of the mtime and size for each tracked file. It knows the TreeId that the working copy represents. It has a snapshot() method that will use the recorded mtimes and sizes and detect changes in the working copy. If anything changed, it will return a new TreeId. It also has checkout() for updating the files on disk to match a requested TreeId.

    The TreeState type supports sparse checkouts. In fact, all working copies are sparse; they simply track the full repo in most cases.

    "},{"location":"technical/architecture/#workingcopy","title":"WorkingCopy","text":"

    The WorkingCopy type has a TreeState but also knows which WorkspaceId it has and at which operation it was most recently updated.

    "},{"location":"technical/architecture/#workspace","title":"Workspace","text":"

    The Workspace type represents the combination of a repo and a working copy ( like Git's 'worktree' concept).

    The repo view at the current operation determines the desired working-copy commit in each workspace. The WorkingCopy determines what is actually in the working copy. The working copy can become stale if the working-copy commit was changed from another workspace (or if the process updating the working copy crashed, for example).

    "},{"location":"technical/architecture/#git","title":"Git","text":"

    The git module contains functionality for interoperating with a Git repo, at a higher level than the GitBackend. The GitBackend is restricted by the Backend trait; the git module is specifically for Git-backed repos. It has functionality for importing refs from the Git repo and for exporting to refs in the Git repo. It also has functionality for pushing and pulling to/from Git remotes.

    "},{"location":"technical/architecture/#revsets","title":"Revsets","text":"

    A user-provided revset expression string goes through a few different stages to be evaluated:

    1. Parse the expression into a RevsetExpression, which is close to an AST
    2. Resolve symbols and functions like tags() into specific commits. After this stage, the expression is still a RevsetExpression, but it won't have any CommitRef variants in it.
    3. Resolve visibility. This stage resolves visible_heads() and all() and produces a ResolvedExpression.
    4. Evaluate the ResolvedExpression into a Revset.

    This evaluation step is performed by Index::evaluate_revset(), allowing the Revset implementation to leverage the specifics of a custom index implementation. The first three steps are independent of the index implementation.

    "},{"location":"technical/architecture/#stackedtable","title":"StackedTable","text":"

    StackedTable (actually ReadonlyTable and MutableTable) is a simple disk format for storing key-value pairs sorted by key. The keys have to have the same size but the values can have different sizes. We use our own format because we want lock-free concurrency and there doesn't seem to be an existing key-value store we could use.

    The file format contains a lookup table followed by concatenated values. The lookup table is a sorted list of keys, where each key is followed by the associated value's offset in the concatenated values.

    A table can have a parent table. When looking up a key, if it's not found in the current table, the parent table is searched. We never update a table in place. If the number of new entries to write is less than half the number of entries in the parent table, we create a new table with the new entries and a pointer to the parent. Otherwise, we copy the entries from the parent table and the new entries into a new table with the grandparent as the parent. We do that recursively so parent tables are at least 2 times as large as child tables. This results in O(log N) amortized insertion time and lookup time.

    There's no garbage collection of unreachable tables yet.

    The tables are named by their hash. We keep a separate directory of pointers to the current leaf tables, in the same way as we do for the operation log.

    "},{"location":"technical/architecture/#design-of-the-cli-crate","title":"Design of the CLI crate","text":""},{"location":"technical/architecture/#templates","title":"Templates","text":"

    The concept is copied from Mercurial, but the syntax is different. The main difference is that the top-level expression is a template expression, not a string like in Mercurial. There is also no string interpolation (e.g. \"Commit ID: {node}\" in Mercurial).

    "},{"location":"technical/architecture/#diff-editing","title":"Diff-editing","text":"

    Diff-editing works by creating two very sparse working copies, containing only the files we want the user to edit. We then let the user edit the right-hand side of the diff. Then we simply snapshot that working copy to create the new tree.

    1. There are a few exceptions, such as for messages printed during automatic upgrades of the repo format\u00a0\u21a9

    "},{"location":"technical/concurrency/","title":"Concurrency","text":""},{"location":"technical/concurrency/#introduction","title":"Introduction","text":"

    Concurrent editing is a key feature of DVCSs -- that's why they're called Distributed Version Control Systems. A DVCS that didn't let users edit files and create commits on separate machines at the same time wouldn't be much of a distributed VCS.

    When conflicting changes are made in different clones, a DVCS will have to deal with that when you push or pull. For example, when using Mercurial, if the remote has updated a bookmark called main (Mercurial's bookmarks are similar to a Git's branches) and you had updated the same bookmark locally but made it point to a different target, Mercurial would add a bookmark called main@origin to indicate the conflict. Git instead prevents the conflict by renaming pulled branches to origin/main whether or not there was a conflict. However, most DVCSs treat local concurrency quite differently, typically by using lock files to prevent concurrent edits. Unlike those DVCSs, Jujutsu treats concurrent edits the same whether they're made locally or remotely.

    One problem with using lock files is that they don't work when the clone is in a distributed file system. Most clones are of course not stored in distributed file systems, but it is a big problem when they are (Mercurial repos frequently get corrupted, for example).

    Another problem with using lock files is related to complexity of implementation. The simplest way of using lock files is to take coarse-grained locks early: every command that may modify the repo takes a lock at the very beginning. However, that means that operations that wouldn't actually conflict would still have to wait for each other. The user experience can be improved by using finer-grained locks and/or taking the locks later. The drawback of that is complexity. For example, you need to verify that any assumptions you made before locking are still valid after you take the lock.

    To avoid depending on lock files, Jujutsu takes a different approach by accepting that concurrent changes can always happen. It instead exposes any conflicting changes to the user, much like other DVCSs do for conflicting changes made remotely.

    "},{"location":"technical/concurrency/#syncing-with-rsync-nfs-dropbox-etc","title":"Syncing with rsync, NFS, Dropbox, etc","text":"

    Jujutsu's lock-free concurrency means that it's possible to update copies of the clone on different machines and then let rsync (or Dropbox, or NFS, etc.) merge them. The working copy may mismatch what's supposed to be checked out, but no changes to the repo will be lost (added commits, moved branches, etc.). If conflicting changes were made, they will appear as conflicts. For example, if a branch was moved to two different locations, they will appear in jj log in both locations but with a \"?\" after the name, and jj status will also inform the user about the conflict.

    Note that, for now, there are known bugs in this area. Most notably, with the Git backend, repository corruption is possible because the backend is not entirely lock-free. If you know about the bug, it is relatively easy to recover from.

    Moreover, such use of Jujutsu is not currently thoroughly tested, especially in the context of co-located repositories. While the contents of commits should be safe, concurrent modification of a repository from different computers might conceivably lose some branch pointers. Note that, unlike in pure Git, losing a branch pointer does not lead to losing commits.

    "},{"location":"technical/concurrency/#operation-log","title":"Operation log","text":"

    The most important piece in the lock-free design is the \"operation log\". That is what allows us to detect and merge concurrent operations.

    The operation log is similar to a commit DAG (such as in Git's object model), but each commit object is instead an \"operation\" and each tree object is instead a \"view\". The view object contains the set of visible head commits, branches, tags, and the working-copy commit in each workspace. The operation object contains a pointer to the view object (like how commit objects point to tree objects), pointers to parent operation(s) (like how commit objects point to parent commit(s)), and metadata about the operation. These types are defined in op_store.proto The operation log is normally linear. It becomes non-linear if there are concurrent operations.

    When a command starts, it loads the repo at the latest operation. Because the associated view object completely defines the repo state, the running command will not see any changes made by other processes thereafter. When the operation completes, it is written with the start operation as parent. The operation cannot fail to commit (except for disk failures and such). It is left for the next command to notice if there were concurrent operations. It will have to be able to do that anyway since the concurrent operation could have arrived via a distributed file system. This model -- where each operation sees a consistent view of the repo and is guaranteed to be able to commit their changes -- greatly simplifies the implementation of commands.

    It is possible to load the repo at a particular operation with jj --at-operation=<operation ID> <command>. If the command is mutational, that will result in a fork in the operation log. That works exactly the same as if any later operations had not existed when the command started. In other words, running commands on a repo loaded at an earlier operation works the same way as if the operations had been concurrent. This can be useful for simulating concurrent operations.

    "},{"location":"technical/concurrency/#merging-concurrent-operations","title":"Merging concurrent operations","text":"

    If Jujutsu tries to load the repo and finds multiple heads in the operation log, it will do a 3-way merge of the view objects based on their common ancestor (possibly several 3-way merges if there were more than two heads). Conflicts are recorded in the resulting view object. For example, if branch main was moved from commit A to commit B in one operation and moved to commit C in a concurrent operation, then main will be recorded as \"moved from A to B or C\". See the RefTarget definition in op_store.proto.

    Because we allow branches (etc.) to be in a conflicted state rather than just erroring out when there are multiple heads, the user can continue to use the repo, including performing further operations on the repo. Of course, some commands will fail when using a conflicted branch. For example, jj checkout main when main is in a conflicted state will result in an error telling you that main resolved to multiple revisions.

    "},{"location":"technical/concurrency/#storage","title":"Storage","text":"

    The operation objects and view objects are stored in content-addressed storage just like Git commits are. That makes them safe to write without locking.

    We also need a way of finding the current head of the operation log. We do that by keeping the ID of the current head(s) as a file in a directory. The ID is the name of the file; it has no contents. When an operation completes, we add a file pointing to the new operation and then remove the file pointing to the old operation. Writing the new file is what makes the operation visible (if the old file didn't get properly deleted, then future readers will take care of that). This scheme ensures that transactions are atomic.

    "},{"location":"technical/conflicts/","title":"First-class conflicts","text":""},{"location":"technical/conflicts/#introduction","title":"Introduction","text":"

    Conflicts can happen when two changes are applied to some state. This document is about conflicts between changes to files (not about conflicts between changes to branch targets, for example).

    For example, if you merge two branches in a repo, there may be conflicting changes between the two branches. Most DVCSs require you to resolve those conflicts before you can finish the merge operation. Jujutsu instead records the conflicts in the commit and lets you resolve the conflict when you feel like it.

    "},{"location":"technical/conflicts/#data-model","title":"Data model","text":"

    When a merge conflict happens, it is recorded as an ordered list of tree objects linked from the commit (instead of the usual single tree per commit). There will always be an odd number of trees linked from the commit. You can think of the first tree as a start tree, and the subsequent pairs of trees to apply the diff between onto the start. Examples:

    • If the commit has trees A, B, C, D, and E it means that the contents should be calculated as A+(C-B)+(E-D).
    • A three-way merge between A and C with B as base can be represented as a commit with trees A, B, and C, also known as A+(C-B).

    The resulting tree contents is calculated on demand. Note that we often don't need to merge the entire tree. For example, when checking out a commit in the working copy, we only need to merge parts of the tree that differs from the tree that was previously checked out in the working copy. As another example, when listing paths with conflicts, we only need to traverse parts of the tree that cannot be trivially resolved; if only one side modified lib/, then we don't need to look for conflicts in that sub-tree.

    When merging trees, if we can't resolve a sub-tree conflict trivially by looking at just the tree id, we recurse into the sub-tree. Similarly, if we can't resolve a file conflict trivially by looking at just the id, we recursive into the hunks within the file.

    See here for how conflicts are stored when using the Git commit backend.

    "},{"location":"technical/conflicts/#conflict-simplification","title":"Conflict simplification","text":"

    Remember that a 3-way merge can be written A+C-B. If one of those states is itself a conflict, then we simply insert the conflict expression there. Then we simplify by removing canceling terms. These two steps are implemented in Merge::flatten() and Merge::simplify() in merge.rs.

    For example, let's say commit B is based on A and is rebased to C, where it results in conflicts (B+C-A), which the user leaves unresolved. If the commit is then rebased to D, the result will be (B+C-A)+(D-C) (D-C comes from changing the base from C to D). That expression can be simplified to B+D-A, which is a regular 3-way merge between B and D with A as base (no trace of C). This is what lets the user keep old commits rebased to head without resolving conflicts and still not get messy recursive conflicts.

    As another example, let's go through what happens when you back out a conflicted commit. Let's say we have the usual B+C-A conflict on top of non-conflict state C. We then back out that change. Backing out (\"reverting\" in Git-speak) a change means applying its reverse diff, so the result is (B+C-A)+(A-(B+C-A)), which we can simplify to just A (i.e. no conflict).

    "}]} \ No newline at end of file diff --git a/prerelease/sitemap.xml.gz b/prerelease/sitemap.xml.gz index d80457c5d2fd9485bdd8f2aa3c40e32c2408ab29..192faee69cc2eb9ef1dea39293c5826bc943676c 100644 GIT binary patch delta 16 Xcmcb@e1(}^zMF$1T8Mii`&mW+C~pLA delta 16 Xcmcb@e1(}^zMF&NEhpDT_OpxtEHVW4