gitbutlerapp/gitbutler · error

Unable to determine the forge for this project. Is target…

Error message

Unable to determine the forge for this project. Is target branch associated with a supported forge?

What it means

`ensure_forge_authentication` resolves the project's forge by deriving forge repo info from the target branch; the info is optional and `None` triggers this anyhow error. Auto-merge enabling, draftiness changes, and review creation all require a recognized forge, so the CLI stops here when the target branch is not associated with a supported forge.

Solutions

  1. Set/verify the push remote URL points at a supported forge (github.com or gitlab.com style URL)
  2. Push the target branch so it is associated with the forge, then retry
  3. Check the project's target-branch assignment (`but target`) and reassign it to a branch on a supported forge
  4. Confirm authentication exists for the forge account (`but auth`) — though the error here fires earlier, at forge detection

Example fix

// before: no forge-associated remote
but review create  // Error: Unable to determine the forge for this project...

// after: point the remote at a supported forge and push the target
git remote set-url origin https://github.com/org/repo.git
git push -u origin my-branch
but review create
Defensive patterns

Strategy: validation

Validate before calling

# ensure remote is a supported forge and target branch is pushed
url=$(git remote get-url --push origin)
echo "$url" | grep -Eq 'github\.com|gitlab\.com' || { echo "unsupported forge remote: $url"; exit 1; }
git ls-remote --heads origin "$(but target --print 2>/dev/null || echo main)" | grep -q . || { echo "target branch not pushed"; exit 1; }

Try / catch

match result {
    Err(e) if e.to_string().contains("Unable to determine the forge") => {
        eprintln!("Fix push remote / target branch so a supported forge is detected.");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling `but review create`, `but forge enable-automerge`, or setting draftiness on a project whose target/push remote does not map to a supported forge (GitHub/GitLab etc.); missing or misconfigured push remote; target branch not set to a branch on a supported forge.

Common situations: Repo with only a generic or self-hosted remote unsupported by but_forge; target branch never pushed so no forge association exists; remote URL changed/renamed so forge detection fails; working in a project without a configured upstream.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/62016ce10c6f2fef. Report an issue: GitHub.

Appendix: source

Thrown at crates/but/src/command/legacy/forge/review.rs:392

    .await
}

/// Make sure that the account that is about to be used in this repository's forge is correctly authenticated.
async fn ensure_forge_authentication(ctx: &mut Context) -> Result<(), anyhow::Error> {
    let (storage, forge_repo_info, preferred_forge_user) = {
        let remote_url = ctx
            .project_meta()?
            .remote_url_with_fallback(&*ctx.repo.get()?)?;
        let forge_repo_info = but_forge::derive_forge_repo_info(&remote_url);
        (
            but_forge_storage::Controller::from_path(but_path::app_data_dir()?),
            forge_repo_info,
            ctx.legacy_project.preferred_forge_user.clone(),
        )
    };

    let forge_repo_info = forge_repo_info.ok_or_else(|| {
        anyhow::anyhow!(
            "Unable to determine the forge for this project. Is target branch associated with a supported forge?"
        )
    })?;

    let account_validity =
        but_forge::check_forge_account_is_valid(preferred_forge_user, &forge_repo_info, &storage)
            .await?;

    let forge_display_name = match forge_repo_info.forge {
        but_forge::ForgeName::Azure => {
            anyhow::bail!("Azure is unsupported at the minute. Sorry 😞.");
        }
        but_forge::ForgeName::GitHub => "GitHub",
        but_forge::ForgeName::GitLab => "GitLab",
        but_forge::ForgeName::Bitbucket => "Bitbucket",
    };

    match account_validity {

View on GitHub (pinned to 58e5313667)