Configuration
These are the config settings available to jj/Jujutsu.
Config files and TOML
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 injj's source repo. -
The user settings. These can be edited with
jj config edit --user. User settings are located in the user config files, which can be found withjj config path --user. -
The repo settings. These can be edited with
jj config edit --repoand are located in.jj/repo/config.toml. -
The workspace settings. These can be edited with
jj config edit --workspaceand are located in.jj/workspace-config.tomlin the workspace root. -
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.
You can enable JSON Schema validation in your editor by adding a #:schema
reference at the top of your TOML config files. See JSON Schema
Support for details.
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.
Dotted style and headings
In TOML, anything under a heading can be dotted instead. For example,
user.name = "YOUR NAME" is equivalent to:
[user]
name = "YOUR NAME"
For future reference, here are a couple of more complicated examples,
# Dotted style
template-aliases."format_short_id(id)" = "id.shortest(12)"
colors."commit_id prefix".bold = true
# is equivalent to:
[template-aliases]
"format_short_id(id)" = "id.shortest(12)"
[colors]
"commit_id prefix" = { bold = true }
The docs below refer to keys in text using dotted notation, but example blocks will use heading notation to be unambiguous. If you are confident with TOML then use whichever suits you in your config. If you mix dotted keys and headings, you must 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.
User settings
[user]
name = "YOUR NAME"
email = "YOUR_EMAIL@example.com"
Don't forget to change these to your own details!
UI settings
Colorizing output
Possible values are always, never, debug and auto (default: auto).
auto will use color only when writing to a terminal. debug will print the
active labels alongside the regular colorized output.
This setting overrides the NO_COLOR environment variable (if set).
[ui]
color = "never" # Turn off color
Custom colors and styles
You can customize the colors used for various elements of the UI. For example:
[colors]
commit_id = "green"
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"
jj also supports colors from the ANSI 256-color palette as ansi-color-<N>,
where <N> is a number between 0 and 255:
[colors]
commit_id = "ansi-color-81"
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, reverse colors (swap foreground and background), or make the text bold, italic, or underlined. For that, you need to use a table:
[colors]
commit_id = { fg = "green", bg = "#ff1525", bold = true, underline = true }
change_id = { reverse = true, italic = true }
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"
"working_copy commit_id" = { underline = true }
Parts of the style that are not overridden - such as the foreground color in the example above - are inherited from the style of the parent label.
Which elements can be colored is not yet documented, but see the default color configuration for some examples of what's possible.
Default command
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", "--reversed"]
Default description
The editor content of a commit description can be populated by the
draft_commit_description template. self is a Commit
object.
[templates]
draft_commit_description = '''
concat(
builtin_draft_commit_description,
"\nJJ: ignore-rest\n",
diff.git(),
)
'''
You can override only the default_commit_description value if you like, e.g.:
[template-aliases]
default_commit_description = '''
"
Closes #NNNN
"
'''
Duplicate commit description
By default, jj duplicate copies the descriptions from the original commits.
You can customize this behavior by specifying the duplicate_description
template, which is given a Commit object of the
original commit.
[templates]
duplicate_description = '''
concat(
description,
"\n(cherry picked from commit ",
commit_id,
")"
)
'''
Bookmark listing order
By default, jj bookmark list displays bookmarks sorted alphabetically by name.
You can customize this sorting behavior by specifying sort keys in your config
file:
[ui]
bookmark-list-sort-keys = ["name"]
The configuration works identically to using the --sort option for
jj bookmark list. The following sort keys are supported: name, author-name,
author-email, author-date, committer-name, committer-email,
committer-date. Suffix the key with - to sort in descending order. Multiple
keys can be supplied here, the first key is the most significant.
When the --sort option is used with jj bookmark list, the configuration
is ignored.
Commit trailers
You can configure automatic addition of one or more trailers to commit
descriptions using the commit_trailers template.
Each line of the template is an individual trailer, usually in Key: Value
format.
Trailers defined in this template are deduplicated with the existing
description: if the entire line of a trailer is already present, it will not be
added again. To deduplicate based only on the trailer key, use the
trailers.contains_key(key) method within the template.
[templates]
commit_trailers = '''
format_signed_off_by_trailer(self)
++ if(!trailers.contains_key("Change-Id"), format_gerrit_change_id_trailer(self))'''
Some ready-to-use trailer templates are available for frequently used trailers:
format_signed_off_by_trailer(commit)creates a "Signed-off-by" trailer using the committer info.format_gerrit_change_id_trailer(commit)creates a "Change-Id" trailer suitable to be used with Gerrit. It is based Jujutsu's change id.
Existing trailers are also accessible via commit.trailers().
Diff colors and styles
In color-words and git diffs, word-level hunks are rendered with underline. You can override the default style with the following keys:
[colors]
# Highlight hunks with background
"diff removed token" = { bg = "#221111", underline = false }
"diff added token" = { bg = "#002200", underline = false }
# Alternatively, swap colors
"diff token" = { reverse = true, underline = false }
Diff format
[ui]
# Builtin formats: ":color-words" (default), ":git",
# ":summary", ":stat", ":types", ":name-only"
# or external command name and arguments (see below)
diff-formatter = ":git"
Color-words diff options
In color-words diffs, changed words are displayed inline by default. Because it's difficult to read a diff line with many removed/added words, there's a threshold to switch to traditional separate-line format. You can also change the default number of lines of context shown.
-
max-inline-alternation: Maximum number of removed/added word alternation to inline. For example,<added> ... <added>sequence has 1 alternation, so the line will be inline ifmax-inline-alternation >= 1.<added> ... <removed> ... <added>sequence has 3 alternation.0: disable inlining, making--color-wordsmore similar to--git1: inline removes-only or adds-only lines2,3, ..: inline up to2,3, .. alternation-1: inline all lines
The default is
3.This parameter is experimental. The definition is subject to change.
-
conflict: How conflicts are processed and displayed."materialize": compare materialized contents (default)"pair": compare individual pairs
This parameter is experimental.
-
context: Number of lines of context to show in the diff. The default is3.
[diff.color-words]
max-inline-alternation = 3
context = 3
Git diff options
In git diffs you can change the default number of lines of context shown.
context: Number of lines of context to show in the diff. The default is3.
[diff.git]
context = 3
Generating diffs by external command
If ui.diff-formatter is not a builtin format, the specified diff command will
be called.
[ui]
# Use Difftastic by default
diff-formatter = ["difft", "--color=always", "$left", "$right"]
# Use tool named "<name>" (see below)
diff-formatter = "<name>"
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>]
# program = "<name>" # Defaults to the name of the tool if not specified
diff-args = ["--color=always", "$left", "$right"]
-
$leftand$rightare replaced with the paths to the left and right directories to diff respectively. -
$widthis replaced with the number of terminal columns available to the diff content. -
If
diff-argsis not specified,["$left", "$right"]will be used by default. -
If
diff-args = [],jjwill refuse to use this tool for diff formatting. This is a way to explicitly state that a certain tool (e.g.mergiraf) does not work for viewing diffs.
By default jj will invoke external tools with a directory containing the left
and right sides. The diff-invocation-mode config can change this to file by file
invocations as follows:
[ui]
diff-formatter = "vimdiff"
[merge-tools.vimdiff]
diff-invocation-mode = "file-by-file"
By default jj will display a warning when the command exits with a non-success
error code. The diff-expected-exit-codes config can suppress this warning
message for specific exit codes:
[merge-tools.delta]
diff-expected-exit-codes = [0, 1]
Conflict marker style
You can configure which style of conflict markers to use when materializing conflicts:
[ui]
# Shows a single snapshot and one or more diffs to apply to it
conflict-marker-style = "diff"
# Shows a snapshot for each side and base of the conflict
conflict-marker-style = "snapshot"
# Uses Git's "diff3" conflict markers to support tools that depend on it
conflict-marker-style = "git"
For more details about these conflict marker styles, see the conflicts page.
Set of immutable commits
You can configure the set of immutable commits via
revset-aliases."immutable_heads()". The default set of immutable heads is
builtin_immutable_heads(), which in turn is defined as
present(trunk()) | tags() | untracked_remote_bookmarks(). For example, to
also consider the release@origin bookmark immutable:
[revset-aliases]
"immutable_heads()" = "builtin_immutable_heads() | release@origin"
To prevent rewriting commits authored by other users:
# The `trunk().. &` bit is an optimization to scan for non-`mine()` commits
# only among commits that are not in `trunk()`.
[revset-aliases]
"immutable_heads()" = "builtin_immutable_heads() | (trunk().. & ~mine())"
Ancestors of the configured set are also immutable. The root commit is always immutable even if the set is empty.
Immutable commits (other than the root commit) can be rewritten using the
--ignore-immutable CLI flag.
!!! warning
Using `--ignore-immutable` will allow you to rewrite any commit in the
history, and all descendants, without warning. Use this power wisely, and
remember `jj undo`.
Behavior of prev and next commands
If you prefer using an "edit-based" workflow, rather than squashing
modifications into parent changes, you may find yourself using the prev and
next commands with their --edit flag often to move between your changes. You
can avoid having to type the --edit flag every time you need it by actually
making it the default:
[ui.movement]
edit = true
You can pass the --no-edit flag to prev and next if you find yourself
needing the original behavior.
List
Default Template
You can configure the template used when no -T is specified.
templates.config_listforjj config list
[templates]
# Use builtin config list template
config_list = "builtin_config_list"
If you want to see the config variable origin (type and path) when you do jj config list
you can add this to your config:
[templates]
config_list = "builtin_config_list_detailed"
Log
Default revisions
Lines 1–500 of 1964. Load more
# Configuration These are the config settings available to jj/Jujutsu. ## Config files and TOML `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 files], 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`. - The workspace settings. These can be edited with `jj config edit --workspace` and are located in `.jj/workspace-config.toml` in the workspace root. - Settings [specified in the command-line](#specifying-config-on-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. You can enable JSON Schema validation in your editor by adding a `#:schema` reference at the top of your TOML config files. See [JSON Schema Support] for details. See the [TOML site] and the [syntax guide] for a detailed description of the syntax. We cover some of the basics below. [the user config files]: #user-config-files [TOML site]: https://toml.io/en/ [syntax guide]: https://toml.io/en/v1.0.0 [JSON Schema Support]: #json-schema-support 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. ### Dotted style and headings In TOML, anything under a heading can be dotted instead. For example, `user.name = "YOUR NAME"` is equivalent to: ```toml [user] name = "YOUR NAME" ``` For future reference, here are a couple of more complicated examples, ```toml # Dotted style template-aliases."format_short_id(id)" = "id.shortest(12)" colors."commit_id prefix".bold = true # is equivalent to: [template-aliases] "format_short_id(id)" = "id.shortest(12)" [colors] "commit_id prefix" = { bold = true } ``` The docs below refer to keys in text using dotted notation, but example blocks will use heading notation to be unambiguous. If you are confident with TOML then use whichever suits you in your config. If you mix dotted keys and headings, **you must 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. ## User settings ```toml [user] name = "YOUR NAME" email = "YOUR_EMAIL@example.com" ``` Don't forget to change these to your own details! ## UI settings ### Colorizing output Possible values are `always`, `never`, `debug` and `auto` (default: `auto`). `auto` will use color only when writing to a terminal. `debug` will print the active labels alongside the regular colorized output. This setting overrides the `NO_COLOR` environment variable (if set). ```toml [ui] color = "never" # Turn off color ``` ### Custom colors and styles You can customize the colors used for various elements of the UI. For example: ```toml [colors] commit_id = "green" ``` 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: ```toml [colors] change_id = "#ff1525" ``` `jj` also supports colors from the [ANSI 256-color palette] as `ansi-color-<N>`, where `<N>` is a number between 0 and 255: ```toml [colors] commit_id = "ansi-color-81" ``` [ANSI 256-color palette]: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit 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, reverse colors (swap foreground and background), or make the text bold, italic, or underlined. For that, you need to use a table: ```toml [colors] commit_id = { fg = "green", bg = "#ff1525", bold = true, underline = true } change_id = { reverse = true, italic = true } ``` 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: ```toml [colors] commit_id = "green" "working_copy commit_id" = { underline = true } ``` Parts of the style that are not overridden - such as the foreground color in the example above - are inherited from the style of the parent label. Which elements can be colored is not yet documented, but see the [default color configuration](https://github.com/jj-vcs/jj/blob/main/cli/src/config/colors.toml) for some examples of what's possible. ### Default command 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"`). ```toml [ui] default-command = ["log", "--reversed"] ``` ### Default description The editor content of a commit description can be populated by the `draft_commit_description` template. `self` is a [`Commit` object](templates.md#commit-type). ```toml [templates] draft_commit_description = ''' concat( builtin_draft_commit_description, "\nJJ: ignore-rest\n", diff.git(), ) ''' ``` You can override only the `default_commit_description` value if you like, e.g.: ```toml [template-aliases] default_commit_description = ''' " Closes #NNNN " ''' ``` ### Duplicate commit description By default, `jj duplicate` copies the descriptions from the original commits. You can customize this behavior by specifying the `duplicate_description` template, which is given a [`Commit` object](templates.md#commit-type) of the original commit. ```toml [templates] duplicate_description = ''' concat( description, "\n(cherry picked from commit ", commit_id, ")" ) ''' ``` ### Bookmark listing order By default, `jj bookmark list` displays bookmarks sorted alphabetically by name. You can customize this sorting behavior by specifying sort keys in your config file: ```toml [ui] bookmark-list-sort-keys = ["name"] ``` The configuration works identically to using the `--sort` option for `jj bookmark list`. The following sort keys are supported: `name`, `author-name`, `author-email`, `author-date`, `committer-name`, `committer-email`, `committer-date`. Suffix the key with `-` to sort in descending order. Multiple keys can be supplied here, the first key is the most significant. When the `--sort` option is used with `jj bookmark list`, the configuration is ignored. ### Commit trailers You can configure automatic addition of one or more trailers to commit descriptions using the `commit_trailers` template. Each line of the template is an individual trailer, usually in `Key: Value` format. Trailers defined in this template are deduplicated with the existing description: if the entire line of a trailer is already present, it will not be added again. To deduplicate based only on the trailer key, use the `trailers.contains_key(key)` method within the template. ```toml [templates] commit_trailers = ''' format_signed_off_by_trailer(self) ++ if(!trailers.contains_key("Change-Id"), format_gerrit_change_id_trailer(self))''' ``` Some ready-to-use trailer templates are available for frequently used trailers: * `format_signed_off_by_trailer(commit)` creates a "Signed-off-by" trailer using the committer info. * `format_gerrit_change_id_trailer(commit)` creates a "Change-Id" trailer suitable to be used with Gerrit. It is based Jujutsu's change id. Existing trailers are also accessible via `commit.trailers()`. ### Diff colors and styles In color-words and git diffs, word-level hunks are rendered with underline. You can override the default style with the following keys: ```toml [colors] # Highlight hunks with background "diff removed token" = { bg = "#221111", underline = false } "diff added token" = { bg = "#002200", underline = false } # Alternatively, swap colors "diff token" = { reverse = true, underline = false } ``` ### Diff format ```toml [ui] # Builtin formats: ":color-words" (default), ":git", # ":summary", ":stat", ":types", ":name-only" # or external command name and arguments (see below) diff-formatter = ":git" ``` #### Color-words diff options In color-words diffs, changed words are displayed inline by default. Because it's difficult to read a diff line with many removed/added words, there's a threshold to switch to traditional separate-line format. You can also change the default number of lines of context shown. * `max-inline-alternation`: Maximum number of removed/added word alternation to inline. For example, `<added> ... <added>` sequence has 1 alternation, so the line will be inline if `max-inline-alternation >= 1`. `<added> ... <removed> ... <added>` sequence has 3 alternation. * `0`: disable inlining, making `--color-words` more similar to `--git` * `1`: inline removes-only or adds-only lines * `2`, `3`, ..: inline up to `2`, `3`, .. alternation * `-1`: inline all lines The default is `3`. **This parameter is experimental.** The definition is subject to change. * `conflict`: How conflicts are processed and displayed. * `"materialize"`: compare materialized contents (default) * `"pair"`: compare individual pairs **This parameter is experimental.** * `context`: Number of lines of context to show in the diff. The default is `3`. ```toml [diff.color-words] max-inline-alternation = 3 context = 3 ``` #### Git diff options In git diffs you can change the default number of lines of context shown. * `context`: Number of lines of context to show in the diff. The default is `3`. ```toml [diff.git] context = 3 ``` ### Generating diffs by external command If `ui.diff-formatter` is not a builtin format, the specified diff command will be called. ```toml [ui] # Use Difftastic by default diff-formatter = ["difft", "--color=always", "$left", "$right"] # Use tool named "<name>" (see below) diff-formatter = "<name>" ``` 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. ```toml [merge-tools.<name>] # program = "<name>" # Defaults to the name of the tool if not specified diff-args = ["--color=always", "$left", "$right"] ``` - `$left` and `$right` are replaced with the paths to the left and right directories to diff respectively. - `$width` is replaced with the number of terminal columns available to the diff content. - If `diff-args` is not specified, `["$left", "$right"]` will be used by default. - If `diff-args = []`, `jj` will refuse to use this tool for diff formatting. This is a way to explicitly state that a certain tool (e.g. `mergiraf`) does not work for viewing diffs. By default `jj` will invoke external tools with a directory containing the left and right sides. The `diff-invocation-mode` config can change this to file by file invocations as follows: ```toml [ui] diff-formatter = "vimdiff" [merge-tools.vimdiff] diff-invocation-mode = "file-by-file" ``` By default `jj` will display a warning when the command exits with a non-success error code. The `diff-expected-exit-codes` config can suppress this warning message for specific exit codes: ```toml [merge-tools.delta] diff-expected-exit-codes = [0, 1] ``` ### Conflict marker style You can configure which style of conflict markers to use when materializing conflicts: ```toml [ui] # Shows a single snapshot and one or more diffs to apply to it conflict-marker-style = "diff" # Shows a snapshot for each side and base of the conflict conflict-marker-style = "snapshot" # Uses Git's "diff3" conflict markers to support tools that depend on it conflict-marker-style = "git" ``` For more details about these conflict marker styles, see the [conflicts page](conflicts.md#conflict-markers). ### Set of immutable commits You can configure the set of immutable commits via `revset-aliases."immutable_heads()"`. The default set of immutable heads is `builtin_immutable_heads()`, which in turn is defined as `present(trunk()) | tags() | untracked_remote_bookmarks()`. For example, to also consider the `release@origin` bookmark immutable: ```toml [revset-aliases] "immutable_heads()" = "builtin_immutable_heads() | release@origin" ``` To prevent rewriting commits authored by other users: ```toml # The `trunk().. &` bit is an optimization to scan for non-`mine()` commits # only among commits that are not in `trunk()`. [revset-aliases] "immutable_heads()" = "builtin_immutable_heads() | (trunk().. & ~mine())" ``` Ancestors of the configured set are also immutable. The root commit is always immutable even if the set is empty. Immutable commits (other than the root commit) can be rewritten using the `--ignore-immutable` CLI flag. !!! warning Using `--ignore-immutable` will allow you to rewrite any commit in the history, and all descendants, without warning. Use this power wisely, and remember `jj undo`. ### Behavior of prev and next commands If you prefer using an "edit-based" workflow, rather than squashing modifications into parent changes, you may find yourself using the `prev` and `next` commands with their `--edit` flag often to move between your changes. You can avoid having to type the `--edit` flag every time you need it by actually making it the default: ```toml [ui.movement] edit = true ``` You can pass the `--no-edit` flag to `prev` and `next` if you find yourself needing the original behavior. ## List ### Default Template You can configure the template used when no `-T` is specified. - `templates.config_list` for `jj config list` ```toml [templates] # Use builtin config list template config_list = "builtin_config_list" ``` If you want to see the config variable origin (type and path) when you do `jj config list` you can add this to your config: ```toml [templates] config_list = "builtin_config_list_detailed" ``` ## Log ### Default revisions