{"record":{"id":"c758de0ecfcb2838","repo":"gitbutlerapp/gitbutler","slug":"no-push-remote-set-or-more-than-one-remote","errorCode":null,"errorMessage":"No push remote set or more than one remote","messagePattern":"No push remote set or more than one remote","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-action/src/lib.rs","lineNumber":149,"sourceCode":"                .project_meta()?\n                .target_ref_or_err()?\n                .to_string()\n                .parse()?;\n            gitbutler_branch_actions::set_base_branch(ctx, &target_ref, perm).map(|_| ())\n        }\n    }\n}\n\nfn default_target_setting_if_none(ctx: &Context) -> anyhow::Result<()> {\n    if ctx.project_meta()?.target_ref.is_some() {\n        return Ok(());\n    }\n    // Lets do the equivalent of `git symbolic-ref refs/remotes/origin/HEAD --short` to guess the default target.\n\n    let repo = ctx.repo.get()?;\n    let remote_name = repo\n        .remote_default_name(gix::remote::Direction::Push)\n        .ok_or_else(|| anyhow::anyhow!(\"No push remote set or more than one remote\"))?\n        .to_string();\n\n    let mut head_ref = repo\n        .find_reference(&format!(\"refs/remotes/{remote_name}/HEAD\"))\n        .map_err(|_| anyhow::anyhow!(\"No HEAD reference found for remote {remote_name}\"))?;\n    let target_ref_name = head_ref\n        .target()\n        .try_name()\n        .ok_or_else(|| anyhow::anyhow!(\"Remote HEAD for {remote_name} is not symbolic\"))?\n        .to_owned();\n\n    let head_commit = head_ref.peel_to_commit()?;\n\n    ctx.set_project_meta(ProjectMeta {\n        target_ref: Some(target_ref_name),\n        target_commit_id: Some(head_commit.id),\n        push_remote: None,\n    })?;","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-action/src/lib.rs#L131-L167","documentation":"When no target branch is configured yet, default_target_setting_if_none guesses the default target by asking the repo for the default push remote (equivalent to `git symbolic-ref refs/remotes/origin/HEAD --short`). gix's remote_default_name returns None when there is no push remote or the choice is ambiguous (more than one remote), so this error is thrown. A unique default remote is required to derive the workspace's target branch.","triggerScenarios":"prepare_handle_changes runs on a project whose ProjectMeta has no target_ref, and repo.remote_default_name(Push) returns None because the repo has zero remotes or multiple remotes with no uniquely dominant push remote.","commonSituations":"A freshly cloned repo with no remote configured; a repo with both 'origin' and 'upstream' (or multiple fork remotes) where the default cannot be inferred; a local-only sandbox repo used for testing.","solutions":["Add or fix a single push remote: `git remote add origin <url>` (remove extra remotes or set remote.pushDefault).","Set the default explicitly: `git config remote.pushDefault origin` so the default remote is unambiguous.","Configure the target branch in the GitButler project settings so default_target_setting_if_none has nothing to guess."],"exampleFix":"// before: ambiguous remotes\n$ git remote -v\nupstream  ...\nfork      ...\n\n// after\n$ git config remote.pushDefault upstream\n# or configure the GitButler target explicitly","handlingStrategy":"validation","validationCode":"let remotes = repo.remotes()?;\nif remotes.len() != 1 && repo.config_snapshot(None)?.get(\"remote.pushDefault\").is_err() {\n    anyhow::bail!(\"set remote.pushDefault or configure the GitButler target explicitly\");\n}","typeGuard":null,"tryCatchPattern":"match default_target_setting_if_none(ctx) {\n    Err(e) if e.to_string().contains(\"No push remote set or more than one remote\") => {\n        // fix git remotes / remote.pushDefault, then retry\n    }\n    other => other?,\n}","preventionTips":["Keep exactly one push remote or set `git config remote.pushDefault <name>`.","Configure the GitButler target branch explicitly in project settings instead of relying on inference.","Verify `git remote -v` output before initializing a workspace in a repo with forks/upstreams."],"tags":["git-remote","configuration","target-branch","ambiguity"],"backgroundTag":"missing-config-value","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"}