gitbutlerapp/gitbutler · error
Gerrit push flags (--wip, --ready, --hashtag/--tag…
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
get_gerrit_flags throws this when Gerrit-specific push flags (--wip, --ready, --hashtag/--tag, --topic, --topic-from-branch, --private) are used while gerrit_mode is not enabled for the repository. These flags only have meaning for Gerrit's push semantics (refs/for/, topics, WIP markers), so the CLI rejects them outright to prevent silently ignored options.
Solutions
- Enable gerrit mode for the repository in GitButler config (repo-level gerrit_mode setting)
- Remove the Gerrit-specific flags if the remote is not a Gerrit server
- Confirm the push target is actually Gerrit; for GitHub/GitLab use their native review flags instead
Example fix
// before but push --topic my-topic // error: requires gerrit_mode // after but config gerrit_mode true but push --topic my-topic
Defensive patterns
Strategy: validation
Validate before calling
// check gerrit_mode before passing Gerrit flags
const gerrit = await runBut(['config', 'gerrit_mode', '--get']);
if (gerrit !== 'true' && gerritFlags.length > 0) {
throw new Error('Enable gerrit_mode or drop Gerrit flags');
} Type guard
function canUseGerritFlags(cfg: { gerrit_mode: boolean }): boolean {
return cfg.gerrit_mode === true;
} Try / catch
try {
await runBut(['push', ...gerritFlags]);
} catch (e) {
if (/can only be used when gerrit_mode is enabled/.test(e.message)) {
await runBut(['config', 'gerrit_mode', 'true']);
return retry();
}
throw e;
} Prevention
- Enable gerrit_mode once per Gerrit repository
- Keep separate command templates for Gerrit vs non-Gerrit remotes
- Audit CI scripts for Gerrit flags before pointing them at new remotes
When it happens
Trigger: Running `but push --wip`, `--ready`, `--topic x`, `--topic-from-branch`, `--private`, or `--hashtag y` (push_single_branch_impl path) on a repo where gerrit_mode is disabled in its configuration.
Common situations: Copy-pasting push commands between Gerrit and non-Gerrit repos, forgetting to enable gerrit_mode after cloning a Gerrit project, or CI scripts assuming Gerrit flags are universally accepted.
Related errors
- Cannot pass both --local and --global
- Hashtag cannot be empty
- --ai cannot be combined with a resolve subcommand. For one…
- Cannot use both --detect and --path options together
- Cannot use both --fix-formatting and --message flags…
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/d68d22d6507ea84c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/push.rs:1045
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 58e5313667)