{"record":{"id":"c472f14f590d9575","repo":"gitbutlerapp/gitbutler","slug":"failed-to-determine-push-remote-for-dry-run-push","errorCode":null,"errorMessage":"Failed to determine push remote for dry-run push: workspace target has no push remote.","messagePattern":"Failed to determine push remote for dry-run push: workspace target has no push remote\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/push.rs","lineNumber":226,"sourceCode":"                t.hint.paint(\"No branches have unpushed commits.\")\n            )?;\n        }\n        return Ok(());\n    }\n\n    // Get detailed information for each branch\n    let mut dry_run_infos = Vec::new();\n\n    let lanes = crate::legacy::workspace::applied_lanes_with_expensive_commit_info(ctx)?;\n\n    // Limit the shared lock to target resolution before continuing with dry-run analysis.\n    let fallback_remote = {\n        let guard = ctx.shared_worktree_access();\n        workspace_target::ResolvedTarget::resolve_with_perm(ctx, guard.read_permission())?\n            .push_remote_name()\n            .map(str::to_owned)\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Failed to determine push remote for dry-run push: workspace target has no push remote.\"\n                )\n            })?\n    };\n    let repo = ctx.repo.get()?.clone().for_commit_shortening();\n    let remote_names = repo.remote_names();\n    for (branch_name, unpushed_count, stack_name) in &branches_to_show {\n        // Find the lane containing this branch\n        for stack_entry in &lanes {\n            if let Some(branch_detail) = stack_entry.branch(branch_name) {\n                let remote_ref = match repo\n                    .branch_remote_tracking_ref_name(\n                        branch_detail.reference.as_ref(),\n                        gix::remote::Direction::Fetch,\n                    )\n                    .transpose()?\n                {\n                    Some(remote_ref) => remote_ref,","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/push.rs#L208-L244","documentation":"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.","triggerScenarios":"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).","commonSituations":"Repos where `origin` was removed or renamed, workspaces set up without a target remote, or SSH/URL config changes that leave push remote unset.","solutions":["Add or restore the remote: `git remote add origin <url>`","Check `git remote -v` and confirm a push URL exists for the workspace target","Re-assign the workspace target to a branch on an existing remote, then retry the dry-run"],"exampleFix":"// before\nbut push --dry-run  // error: workspace target has no push remote\n// after\ngit remote add origin git@github.com:org/repo.git\nbut push --dry-run","handlingStrategy":"validation","validationCode":"// verify a push remote exists before dry-run\nconst remotes = execSync('git remote -v').toString();\nif (!/\\(push\\)/.test(remotes)) {\n  throw new Error('No push remote configured');\n}","typeGuard":"function hasPushRemote(t: ResolvedTarget): t is ResolvedTarget & { pushRemote: string } {\n  return typeof t.pushRemoteName?.() === 'string';\n}","tryCatchPattern":"try {\n  await runBut(['push', '--dry-run']);\n} catch (e) {\n  if (/has no push remote/.test(e.message)) {\n    execSync('git remote add origin <url>');\n    return retry();\n  }\n  throw e;\n}","preventionTips":["Keep `origin` (or an explicit push remote) configured in .git/config","Re-check remotes after cloning via non-standard setups","Run `git remote -v` as a preflight in scripts"],"tags":["cli","push","dry-run","remote","missing-config"],"backgroundTag":"missing-required-config","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}