Jujutsu - ArchWiki

Jump to content

# Jujutsu

From ArchWiki

Jujutsu (commonly referred to as jj) is a modern, Git-compatible version control system written in Rust that aims to be both simpler and more powerful than Git.

## Installation

Install the jujutsu package.

### Graphical front-ends

See also Community-built tools around Jujutsu.

- gg — A GUI for the version control system Jujutsu.

  https://github.com/gulbanana/gg || gg-jujutsuAUR

- jjui — TUI designed for interacting with the Jujutsu version control system.

  https://github.com/idursun/jjui || jjuiAUR

- jj-fzf — Text UI based on fzf, centering around the jj log with key bindings for common operations.

  https://github.com/tim-janik/jj-fzf || jj-fzfAUR

- lazyjj — TUI for jujutsu/jj.

  https://github.com/Cretezy/lazyjj || lazyjj

### Useful tools

Jujutsu can be configured to use alternative tools for tasks such as diff viewing, diff editing, merging. Many tools built for Git also support Jujutsu. The following tools directly or indirectly support Jujutsu and thus can either be used out-of-the-box or after simple adjustment to the Jujutsu configuration file.

#### Conflict resolution

- KDiff3 — File and directory diff and merge tool for the KDE desktop.

  https://apps.kde.org/kdiff3/ || kdiff3

- Meld — Visual diff and merge tool that can compare files, directories, and version controlled projects.

  https://meldmerge.org/ || meld

- Mergiraf — A syntax-aware Git merge driver for a growing collection of programming languages and file formats.

  https://mergiraf.org/ || mergiraf

- Vimdiff — Vim's built-in diff editor.

  https://www.vim.org/ || vim

#### Diff viewing

- delta — A diff viewer written in Rust with syntax highlighting.

  https://github.com/dandavison/delta || git-delta

- difftastic — Compares files using their syntax trees.

  https://difftastic.wilfred.me.uk || difftastic

## Configuration

Just like with most other VCSes, you need to at least configure a name and email that will be attached to your commits.

    $ jj config set --user user.name  "John Doe"
    $ jj config set --user user.email "johndoe@example.com"

The `--user` option tells Jujutsu to set these options in the global configuration file, stored in `~/.config/jj/config.toml`.

Alternatively, `jj config edit --user` opens the configuration file in your default text editor (defined in the `$EDITOR`/`$VISUAL` environment variable or can be set with the `ui.editor` configuration option).

See #Tips and tricks for more settings.

## Usage

All Jujutsu commands are initiated with the `jj` prefix. To see a list of some of the common commands, run

    $ jj help

Each command has a help page that can be read using either of:

    $ jj help subcommand
    $ jj subcommand --help

You can get brief help with the `-h` option.

### Initializing repository

Jujutsu uses Git as a storage backend, so it is compatible with existing Git repositories. Since version 0.34.0, Jujutsu creates colocated repositories by default, so no additional configuration is required to use it with Git. The following command initializes a repository in the current directory:

    $ jj git init

Similarly to Git, it optionally takes a repository destination path as an argument.

As a result, it will create `.jj` and `.git` folders to store its data. As of version 0.38.0, there is no `jj init` yet.

To clone a remote Git repository, use

    $ jj git clone

Just as with `jj git init`, the local copy of the cloned repository will be colocated.

The `jj git colocation` family of commands can be used to view the current status of colocation and optionally enable/disable it. You can find more info in the relevant Jujutsu documentation page.

### Authenticating with remote hosts

Jujutsu uses Git under the hood for all remote operations, such as pushing and fetching, and thus all authentication tasks are also handled by Git. Starting from version 0.6.0, `jj git` subcommands support Git's credential helpers, and since v0.30.0, Jujutsu fully supports SSH authentication.

With that said, to use a credential helper with Jujutsu, you need to configure Git. See Git#Using git-credential-libsecret as credential-helper for instructions.

For SSH authentication, create an SSH key and then add it to your account on the hosting service. Relevant instructions can be found in your host's documentation.

## Tips and tricks

### Use Neovim as a vimdiff backend

Jujutsu has the `--tool vimdiff` option to use Vim as a diff editor, but it doesn't detect Neovim. Add this to your configuration file to use `nvim` instead:

    ~/.config/jj/config.toml

    [merge-tools.vimdiff]
    program = "nvim"

Alternatively, you can add your own merge-tools as described in Jujutsu documentation here.

## See also

- Official Jujutsu documentation
- JJ wiki on Github
- Awesome-jj - Curated list of learning materials, tools and other jj things

Categories:

- Version control system
- Commands

Jujutsu
Add topic