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 initwrites 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):
- Command-line flags (e.g.,
--github-repository) - Jujutsu user config (
~/.jjconfig.toml) - Jujutsu repository config (
.jj/repo/config.toml) - Git repository config (
.git/config) ← wherejj spr initwrites - Environment variables (e.g.,
GITHUB_TOKEN) - 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 key | CLI flag | description | default1 | default in jj spr init2 |
|---|---|---|---|---|
githubAuthToken | --github-auth-token3 | The GitHub PAT (personal authentication token) to use for accessing the GitHub API. | ||
githubRemoteName | Name of the git remote in this local repository that corresponds to GitHub | origin | origin | |
githubRepository | --github-repository | Name of repository on github.com in owner/repo format | extracted from the URL of the GitHub remote | |
githubMasterBranch | The name of the centrally shared branch into which the pull requests are merged | main | taken from repository configuration on GitHub | |
branchPrefix | --branch-prefix | String used to prefix autogenerated names of pull request branches | jj-spr/GITHUB_USERNAME/ | |
requireApproval | If true, jj spr land will refuse to land a pull request that is not approved | false | true |
Notes:
- All config keys are in the
sprsection; for example,spr.githubAuthToken. - Values passed on the command line take precedence over values set in configuration.
Setting Configuration
Option 1: Using jj spr init (Recommended)
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 configuringgithubAuthTokenJJ_SPR_BRANCH_PREFIX: Override forbranchPrefixconfig