Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

The recommended way to configure jj-spr is to run jj spr init, rather than setting config values manually. You can rerun jj spr init to update config at any time.

Configuration Storage

ℹ️ Hybrid Configuration System: jj-spr uses a dual-layer configuration approach that bridges Git and Jujutsu config systems.

How it works:

  • jj spr init writes configuration to your repository’s git config (.git/config)
  • At runtime, jj-spr reads from Jujutsu config first, then falls back to git config

Configuration is stored in git config but jj-spr reads from Jujutsu config first, then falls back to git config.

Configuration priority (highest to lowest):

  1. Command-line flags (e.g., --github-repository)
  2. Jujutsu user config (~/.jjconfig.toml)
  3. Jujutsu repository config (.jj/repo/config.toml)
  4. Git repository config (.git/config) ← where jj spr init writes
  5. Environment variables (e.g., GITHUB_TOKEN)
  6. Built-in defaults

This design allows:

  • Easy initial setup via jj spr init (writes to git config)
  • Flexibility to override settings in Jujutsu config if preferred
  • Compatibility with both git-based and jj-native workflows

Configuration Values

jj-spr uses the following configuration values:

config keyCLI flagdescriptiondefault1default in jj spr init2
githubAuthToken--github-auth-token3The GitHub PAT (personal authentication token) to use for accessing the GitHub API.
githubRemoteNameName of the git remote in this local repository that corresponds to GitHuboriginorigin
githubRepository--github-repositoryName of repository on github.com in owner/repo formatextracted from the URL of the GitHub remote
githubMasterBranchThe name of the centrally shared branch into which the pull requests are mergedmaintaken from repository configuration on GitHub
branchPrefix--branch-prefixString used to prefix autogenerated names of pull request branchesjj-spr/GITHUB_USERNAME/
requireApprovalIf true, jj spr land will refuse to land a pull request that is not approvedfalsetrue

Notes:

  • All config keys are in the spr section; for example, spr.githubAuthToken.
  • Values passed on the command line take precedence over values set in configuration.

Setting Configuration

The easiest way to configure jj-spr:

jj spr init

This writes settings to git config (.git/config).

Option 2: Using git config commands

Since jj spr init writes to git config, you can modify settings with git commands:

# Set configuration values
git config spr.githubAuthToken "your-token"
git config spr.branchPrefix "my-prefix/"

Option 3: Using jj config set

If you prefer Jujutsu’s native config, you can override git config settings:

# Set repository-specific config (highest priority)
jj config set --repo spr.githubAuthToken "your-token"

# Set user-specific config (applies to all repos)
jj config set --user spr.branchPrefix "my-prefix/"

Option 4: Editing config files directly

Git config (.git/config) - where jj spr init writes:

[spr]
githubAuthToken = "ghp_..."
githubRepository = "owner/repo"
githubRemoteName = "origin"
githubMasterBranch = "main"
branchPrefix = "jj-spr/username/"
requireApproval = true

Jujutsu config (.jj/repo/config.toml) - overrides git config:

[spr]
# Any values here override git config
githubAuthToken = "ghp_..."

Jujutsu-Specific Configuration

In addition to jj-spr settings, you may want to configure Jujutsu itself for optimal workflow:

# Recommended Jujutsu settings for jj-spr workflow
[ui]
default-command = "log"
pager = "less -FRX"

[git]
# Prefix for branches pushed to GitHub
push-branch-prefix = "jj-spr/"

[revset-aliases]
# Useful revsets for jj-spr workflow
'mine' = 'author(exact:"your.email@example.com")'
'ready' = 'mine & description(regex:"^(?!wip:)")'
'has-pr' = 'mine & description(regex:"Pull Request:")'

[templates]
# Custom log format showing PR numbers
'log' = '''
label(if(current_working_copy, "bold"),
  concat(
    separate(" ",
      label("cyan", change_id.shortest(8)),
      label("magenta", if(description, description.first_line(), "(no description)"))
    ),
    if(description.match("Pull Request: .*(#\\d+)"),
      label("green", " " ++ description.match("Pull Request: .*(#\\d+)")))
  )
)
'''

Environment Variables

jj-spr also respects certain environment variables:

  • GITHUB_TOKEN: Can be used instead of configuring githubAuthToken
  • JJ_SPR_BRANCH_PREFIX: Override for branchPrefix config

  1. Value used by jj spr if not set in configuration.

  2. Value suggested by jj spr init if not previously configured.

  3. Be careful using this: your auth token will be in your shell history.