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 --repo, or found withjj config path --repo. For security reasons, they are not located inside the repo. -
The workspace settings. These can be edited with
jj config edit --workspace, or found withjj config path --workspace. For security reasons, they are not located inside the workspace. -
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, dim, 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, dim = false, 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.trim_end(),
"\n\n(cherry picked from commit ",
commit_id,
")\n"
)
'''
Note that description usually ends with a \n if it is not blank. Use
.trim_end() to remove the \n.
New commit description
When jj new creates a commit without an explicit -m message, it evaluates
the new_description template to populate the description. By default, this
template is empty.
You can customize this to automatically generate descriptions for new commits. For example, to auto-generate merge commit messages:
[templates]
new_description = '''
if(parents.len() > 1,
"Merge " ++ parents.skip(1).map(|p| if(
p.bookmarks(),
p.bookmarks().first().name(),
p.change_id().shortest(8)
)).join(", ") ++ " into " ++ if(
parents.first().bookmarks(),
parents.first().bookmarks().first().name(),
parents.first().change_id().shortest(8)
) ++ "\n",
""
)
'''
Bookmark/tag listing order
By default, jj bookmark list and jj tag list display bookmarks and tags
sorted alphabetically by name. You can customize this sorting behavior by
specifying sort keys in your config file:
[ui]
bookmark-list-sort-keys = ["name"]
tag-list-sort-keys = ["name"]
The configuration works identically to using the --sort option. 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, 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 }
In color-words diffs, line numbers of context lines are rendered with decreased intensity to highlight changed lines. You can also decrease intensity of context contents.
[colors]
# Dim context line numbers (default)
"diff context line_number" = { dim = true }
# Dim context line numbers and contents (applies to color-words and git diffs)
"diff context" = { dim = true }
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 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`.
Lines 1–500 of 2138. 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`, or found with `jj config path --repo`. For security reasons, they are not located inside the repo. - The workspace settings. These can be edited with `jj config edit --workspace`, or found with `jj config path --workspace`. For security reasons, they are not located inside the workspace. - 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, dim, 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, dim = false, 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.trim_end(), "\n\n(cherry picked from commit ", commit_id, ")\n" ) ''' ``` Note that `description` usually ends with a `\n` if it is not blank. Use `.trim_end()` to remove the `\n`. ### New commit description When `jj new` creates a commit without an explicit `-m` message, it evaluates the `new_description` template to populate the description. By default, this template is empty. You can customize this to automatically generate descriptions for new commits. For example, to auto-generate merge commit messages: ```toml [templates] new_description = ''' if(parents.len() > 1, "Merge " ++ parents.skip(1).map(|p| if( p.bookmarks(), p.bookmarks().first().name(), p.change_id().shortest(8) )).join(", ") ++ " into " ++ if( parents.first().bookmarks(), parents.first().bookmarks().first().name(), parents.first().change_id().shortest(8) ) ++ "\n", "" ) ''' ``` ### Bookmark/tag listing order By default, `jj bookmark list` and `jj tag list` display bookmarks and tags 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"] tag-list-sort-keys = ["name"] ``` The configuration works identically to using the `--sort` option. 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, 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 } ``` In color-words diffs, line numbers of context lines are rendered with decreased intensity to highlight changed lines. You can also decrease intensity of context contents. ```toml [colors] # Dim context line numbers (default) "diff context line_number" = { dim = true } # Dim context line numbers and contents (applies to color-words and git diffs) "diff context" = { dim = true } ``` ### 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 `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`.