{"record":{"id":"54208004c43415c5","repo":"gitbutlerapp/gitbutler","slug":"couldn-t-find-remote-refspecs-that-would-match","errorCode":null,"errorMessage":"Couldn't find remote refspecs that would match {}","messagePattern":"Couldn't find remote refspecs that would match (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/branch/mod.rs","lineNumber":605,"sourceCode":"/// Return the local tracking branch of `remote_tracking_ref`, creating it at the remote-tracking\n/// commit with tracking configuration if it doesn't exist yet, like `git checkout <name>` does.\n///\n/// An existing local tracking branch is returned as is, even if it diverged from the remote.\npub fn local_tracking_branch(\n    repo: &gix::Repository,\n    remote_tracking_ref: &gix::refs::FullNameRef,\n) -> anyhow::Result<gix::refs::FullName> {\n    // Symbolic ones, `origin/HEAD` say, would make a local branch of the name they point through.\n    if try_find_validated_ref(repo, remote_tracking_ref, \"check out\")?.is_none() {\n        anyhow::bail!(\n            \"Remote-tracking branch {} does not exist\",\n            remote_tracking_ref.as_bstr()\n        );\n    }\n    let Some((local_tracking_ref, _remote)) =\n        repo.upstream_branch_and_remote_for_tracking_branch(remote_tracking_ref)?\n    else {\n        anyhow::bail!(\n            \"Couldn't find remote refspecs that would match {}\",\n            remote_tracking_ref.as_bstr()\n        );\n    };\n    if repo\n        .try_find_reference(local_tracking_ref.as_ref())?\n        .is_some()\n    {\n        return Ok(local_tracking_ref);\n    }\n\n    let (config, commit_id) =\n        setup_local_tracking_configuration(repo, local_tracking_ref.as_ref(), remote_tracking_ref)?;\n    // The reference first, as git does: should it fail, the config transaction drops unwritten.\n    repo.reference(\n        local_tracking_ref.as_ref(),\n        commit_id,\n        gix::refs::transaction::PreviousValue::MustNotExist,","sourceCodeStart":587,"sourceCodeEnd":623,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-workspace/src/branch/mod.rs#L587-L623","documentation":"After confirming the remote-tracking ref exists, local_tracking_branch asks gix for the local branch that the tracking ref maps to via the remote's fetch refspecs. When no refspec matches, there is no local branch to return and the function bails.","triggerScenarios":"Calling local_tracking_branch with an existing remote-tracking ref whose remote config lacks a matching fetch refspec, so upstream_branch_and_remote_for_tracking_branch returns None.","commonSituations":"Manually created tracking refs (e.g. via `git update-ref refs/remotes/upstream/x`) with no corresponding remote fetch refspec; remotes configured only with push refspecs.","solutions":["Add the standard wildcard fetch refspec: `git config remote.<name>.fetch \"+refs/heads/*:refs/remotes/<name>/*\"`","Create the tracking ref via a normal `git fetch <remote>` so refspec-based mapping exists","Use a tracking ref that belongs to a properly configured remote"],"exampleFix":"// before (config)\n[remote \"origin\"]\n  url = ...\n  push = +refs/heads/*:refs/heads/*\n// after (config)\n[remote \"origin\"]\n  url = ...\n  fetch = +refs/heads/*:refs/remotes/origin/*","handlingStrategy":"validation","validationCode":"fn refspec_covers(repo: &gix::Repository, tracking: &gix::refs::FullNameRef) -> anyhow::Result<bool> {\n    Ok(repo.upstream_branch_and_remote_for_tracking_branch(tracking)?.is_some())\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"Couldn't find remote refspecs\") => {\n        eprintln!(\"add remote.<name>.fetch = +refs/heads/*:refs/remotes/<name>/*\");\n        anyhow::bail!(e);\n    }\n    other => other,\n}","preventionTips":["Create tracking refs via git fetch, not update-ref, so refspec mapping exists","Ensure each remote has a fetch (not just push) refspec","Test refspec coverage after editing .git/config by hand"],"tags":["git","refspec","config"],"backgroundTag":"invalid-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"}