gitbutlerapp/gitbutler · error

--ai cannot be combined with a resolve subcommand. For one c

Error message

--ai cannot be combined with a resolve subcommand. For one conflict, use `but resolve apply <path>[:<N>] --ai` instead.

What it means

The global `--ai` flag is mutually exclusive with `but resolve` subcommands (`conflicts`, `apply`, `cancel`, ...). Passing both bails immediately (resolve.rs:55-59), pointing you to the supported AI form for a single conflict: `but resolve apply <path>[:<N>] --ai`, which carries its own AI flag after the subcommand.

Source

Thrown at crates/but/src/command/legacy/resolve.rs:57

        [] => None,
        [target] if !conflicted_paths.contains(target) => Some(target.clone()),
        _ => {
            if let Some(other) = targets.iter().find(|t| !conflicted_paths.contains(t)) {
                bail!(
                    "'{other}' is not a conflicted uncommitted file; `but resolve` takes either one commit or only conflicted files (see `but status`)."
                );
            }
            if ai {
                bail!(
                    "Conflicted uncommitted files can only be marked as resolved: `but resolve <path>...`"
                );
            }
            return mark_worktree_conflicts_resolved(ctx, out, targets);
        }
    };
    if ai {
        if cmd.is_some() {
            bail!(
                "--ai cannot be combined with a resolve subcommand. For one conflict, use `but resolve apply <path>[:<N>] --ai` instead."
            );
        }
        return resolve_with_ai(ctx, out, commit_id.as_deref());
    }
    match cmd {
        Some(Subcommands::Conflicts { commit }) => list_conflicts(ctx, out, commit.as_deref()),
        Some(Subcommands::Apply {
            target,
            commit,
            ours,
            theirs,
            ai,
            file,
        }) => {
            let flags = ResolutionFlags {
                ours,
                theirs,

View on GitHub (pinned to caf1f223d3)

Solutions

  1. For whole-commit AI resolution use `but resolve --ai <commit-id>` with no subcommand.
  2. For one conflict or hunk use `but resolve apply <path>[:<N>] --ai`.
  3. Drop `--ai` entirely when you genuinely want the subcommand's non-AI behavior.

Example fix

# before
but resolve --ai conflicts          # subcommand after global --ai -> not allowed

# after
but resolve conflicts               # list conflicts
but resolve --ai 4z                 # AI-resolve a whole conflicted commit
but resolve apply src/lib.rs:2 --ai # AI-resolve one conflict
Defensive patterns

Strategy: validation

Validate before calling

# Keep the global --ai and subcommands mutually exclusive in wrappers
if [[ "$1" == '--ai' && "$2" =~ ^(conflicts|apply|cancel|finish)$ ]]; then
  echo '--ai cannot be combined with a resolve subcommand'; exit 2
fi

Prevention

When it happens

Trigger: `but resolve --ai conflicts`, `but resolve --ai apply <path>`, or any resolve subcommand placed after the global `--ai` flag.

Common situations: Habitual global-flag placement (flags before the subcommand); scripts written for the older bare `--ai` behavior being extended with subcommands.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/aa7ab53788c951b5. Report an issue: GitHub.