gitbutlerapp/gitbutler · error
Gerrit push flags (--wip, --ready, --hashtag/--tag, --topic,
Error message
Gerrit push flags (--wip, --ready, --hashtag/--tag, --topic, --topic-from-branch, --private) can only be used when gerrit_mode is enabled for this repository
What it means
`but push` reads gerrit mode from the repo's Git setting `gitbutler.gerritMode` (default false) and `get_gerrit_flags` refuses any of --wip, --ready, --hashtag/--tag, --topic, --topic-from-branch, or --private when gerrit mode is off. These flags only make sense for Gerrit's refs/for push targets, so a plain push rejects them up front.
Source
Thrown at crates/but/src/command/legacy/push.rs:1053
branches_info.sort_by(|a, b| a.2.cmp(&b.2).then(a.0.cmp(&b.0)));
Ok(branches_info)
}
pub fn get_gerrit_flags(
args: &Command,
branch_name: &str,
gerrit_mode: bool,
) -> anyhow::Result<Vec<but_gerrit::PushFlag>> {
let has_gerrit_flag = args.wip
|| args.ready
|| !args.hashtag.is_empty()
|| args.topic.is_some()
|| args.topic_from_branch
|| args.private;
if has_gerrit_flag && !gerrit_mode {
return Err(anyhow::anyhow!(
"Gerrit push flags (--wip, --ready, --hashtag/--tag, --topic, --topic-from-branch, --private) can only be used when gerrit_mode is enabled for this repository"
));
}
if !gerrit_mode {
return Ok(vec![]);
}
let mut flags = Vec::new();
// Handle Wip/Ready - Ready is default if neither is specified
if args.wip {
flags.push(but_gerrit::PushFlag::Wip);
} else {
// Default to Ready, or explicit Ready
flags.push(but_gerrit::PushFlag::Ready);
}
View on GitHub (pinned to caf1f223d3)
Solutions
- Enable gerrit mode for this repo: `git config gitbutler.gerritMode true` (or the equivalent GitButler setting)
- Or drop the flags: `but push`
- Verify with `git config --get gitbutler.gerritMode`
- Keep Gerrit-specific aliases scoped to Gerrit clones
Example fix
# before but push --wip # error: Gerrit push flags ... can only be used when gerrit_mode is enabled # after git config gitbutler.gerritMode true but push --wip
Defensive patterns
Strategy: validation
Validate before calling
# Gate Gerrit flags on the repo setting if [ "$(git config --bool gitbutler.gerritMode)" = "true" ]; then but push --wip "$@" else but push "$@" fi
Type guard
fn gerrit_flags_allowed(repo: &gix::Repository) -> anyhow::Result<bool> {
Ok(repo.git_settings()?.gitbutler_gerrit_mode.unwrap_or(false))
} Prevention
- Set gitbutler.gerritMode in repo bootstrap scripts for Gerrit projects
- Scope Gerrit push aliases to Gerrit repos only
- Check `git config --get gitbutler.gerritMode` before scripting Gerrit flags
When it happens
Trigger: Running `but push --wip` (or any listed flag) in a repository where `git config gitbutler.gerritMode` is unset or false.
Common situations: Dotfiles or aliases carrying Gerrit flags into non-Gerrit repos; gerritMode config lost after re-cloning; a team template assumes Gerrit but the repo never opted in.
Related errors
- failed to determine remote for non remote-tracking branch {t
- Neither found push remote found in workspace nor unambiguous
- Hashtag cannot be empty
- Topic cannot be empty
- Failed to determine Gerrit target branch
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/d68d22d6507ea84c.
Report an issue: GitHub.