gitbutlerapp/gitbutler · error

Failed to determine push remote for dry-run push: workspace…

Error message

Failed to determine push remote for dry-run push: workspace target has no push remote.

What it means

handle_dry_run throws this when resolving the workspace target via ResolvedTarget::resolve_with_perm yields no push remote name, so the dry-run cannot simulate where the push would land. The fallback remote computation is mandatory for a meaningful dry-run.

Solutions

  1. Add or restore the remote: `git remote add origin <url>`
  2. Check `git remote -v` and confirm a push URL exists for the workspace target
  3. Re-assign the workspace target to a branch on an existing remote, then retry the dry-run

Example fix

// before
but push --dry-run  // error: workspace target has no push remote
// after
git remote add origin git@github.com:org/repo.git
but push --dry-run
Defensive patterns

Strategy: validation

Validate before calling

// verify a push remote exists before dry-run
const remotes = execSync('git remote -v').toString();
if (!/\(push\)/.test(remotes)) {
  throw new Error('No push remote configured');
}

Type guard

function hasPushRemote(t: ResolvedTarget): t is ResolvedTarget & { pushRemote: string } {
  return typeof t.pushRemoteName?.() === 'string';
}

Try / catch

try {
  await runBut(['push', '--dry-run']);
} catch (e) {
  if (/has no push remote/.test(e.message)) {
    execSync('git remote add origin <url>');
    return retry();
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `but push --dry-run` on a workspace whose target has no push remote configured (remote missing from .git/config, or target resolution returns None for push remote).

Common situations: Repos where `origin` was removed or renamed, workspaces set up without a target remote, or SSH/URL config changes that leave push remote unset.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


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

Appendix: source

Thrown at crates/but/src/command/legacy/push.rs:226

                t.hint.paint("No branches have unpushed commits.")
            )?;
        }
        return Ok(());
    }

    // Get detailed information for each branch
    let mut dry_run_infos = Vec::new();

    let lanes = crate::legacy::workspace::applied_lanes_with_expensive_commit_info(ctx)?;

    // Limit the shared lock to target resolution before continuing with dry-run analysis.
    let fallback_remote = {
        let guard = ctx.shared_worktree_access();
        workspace_target::ResolvedTarget::resolve_with_perm(ctx, guard.read_permission())?
            .push_remote_name()
            .map(str::to_owned)
            .ok_or_else(|| {
                anyhow::anyhow!(
                    "Failed to determine push remote for dry-run push: workspace target has no push remote."
                )
            })?
    };
    let repo = ctx.repo.get()?.clone().for_commit_shortening();
    let remote_names = repo.remote_names();
    for (branch_name, unpushed_count, stack_name) in &branches_to_show {
        // Find the lane containing this branch
        for stack_entry in &lanes {
            if let Some(branch_detail) = stack_entry.branch(branch_name) {
                let remote_ref = match repo
                    .branch_remote_tracking_ref_name(
                        branch_detail.reference.as_ref(),
                        gix::remote::Direction::Fetch,
                    )
                    .transpose()?
                {
                    Some(remote_ref) => remote_ref,

View on GitHub (pinned to 58e5313667)