gitbutlerapp/gitbutler · error

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

Error message

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

What it means

Forge review creation derives the forge (GitHub/GitLab/Bitbucket/Azure) from the project's remote URL via but_forge::derive_forge_repo_info; this error fires when that returns None — the target branch's remote URL doesn't map to any supported forge. It is a pre-check before account validation and API calls, telling you the project/remote configuration, not the network, is the blocker.

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 caf1f223d3)

Solutions

  1. Check `git remote -v` — the target branch's remote must point at a github.com/gitlab.com/bitbucket.org (or Azure DevOps) URL.
  2. Re-add a proper remote URL if it's missing/odd: `git remote set-url origin git@github.com:owner/repo.git`.
  3. Ensure the target branch actually tracks that remote (upstream is set) so the correct URL is picked.
  4. If your forge is self-hosted and unsupported, review creation can't proceed — use the forge's own tooling.

Example fix

# before
$ git remote -v
origin  https://gitea.internal/acme/repo.git (fetch)
$ but forge review create
Error: Unable to determine the forge for this project. Is target branch associated with a supported forge?

# after: point at a supported forge
$ git remote set-url origin git@github.com:acme/repo.git
$ but forge review create
Defensive patterns

Strategy: validation

Validate before calling

// Check forge support before starting review creation
let url = ctx.project_meta()?.remote_url_with_fallback(&*ctx.repo.get()?)?;
if but_forge::derive_forge_repo_info(&url).is_none() {
    eprintln!("remote '{url}' is not a supported forge (GitHub/GitLab/Bitbucket/Azure)");
    return Ok(());
}

Type guard

fn supported_forge(url: &str) -> Option<but_forge::ForgeRepoInfo> {
    but_forge::derive_forge_repo_info(&BString::from(url))
}

Try / catch

match create_review(ctx).await {
    Err(e) if e.to_string().contains("Unable to determine the forge") => {
        // configuration problem: fix remote URL, do not retry blindly
        Err(anyhow!("set the target branch upstream to a GitHub/GitLab/Bitbucket remote first"))
    }
    other => other,
}

Prevention

When it happens

Trigger: Target branch tracking a remote whose URL is a private/unrecognized host (self-hosted Gitea/Gogs/Phabricator), a malformed or empty remote URL (with fallback to the repo's remote also failing), or SSH URLs whose host parsing doesn't match a known forge domain.

Common situations: Enterprise mirrors on internal domains; repos cloned from sourceforge-like hosts; remote renamed/broken so remote_url_with_fallback yields something unusable; forks configured with a git:// URL.

Related errors


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