{"record":{"id":"89bdc6c5b708254b","repo":"jdx/mise","slug":"global-configuration-branch-differs-from-the-trans","errorCode":null,"errorMessage":"global configuration branch differs from the transferred branch","messagePattern":"global configuration branch differs from the transferred branch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote_repository.rs","lineNumber":261,"sourceCode":"    git(\n        &checkout,\n        &[\"-c\", \"core.hooksPath=/dev/null\", \"checkout\", &branch],\n    )?;\n    if destination.join(\".git\").exists() {\n        if git(destination, &[\"remote\", \"get-url\", \"origin\"])? != origin {\n            bail!(\"global configuration origin does not match\");\n        }\n        if !git(\n            destination,\n            &[\"status\", \"--porcelain\", \"--untracked-files=no\"],\n        )?\n        .is_empty()\n        {\n            bail!(\"global configuration has uncommitted changes\");\n        }\n        if update {\n            if git(destination, &[\"symbolic-ref\", \"--short\", \"HEAD\"])? != branch {\n                bail!(\"global configuration branch differs from the transferred branch\");\n            }\n            if dry_run {\n                // the bundle holds the history from the checkout's commit on,\n                // so the fast-forward is checked there without fetching into\n                // the destination\n                let head = git(destination, &[\"rev-parse\", \"HEAD\"])?;\n                if head == revision {\n                    miseprintln!(\n                        \"Would keep {shown} at {revision}, already the transferred revision\"\n                    );\n                } else if git(&checkout, &[\"merge-base\", \"--is-ancestor\", &head, revision]).is_ok()\n                {\n                    miseprintln!(\"Would fast-forward {shown} from {head} to {revision}\");\n                } else {\n                    bail!(\n                        \"global configuration at {shown} cannot be fast-forwarded to the transferred revision\"\n                    );\n                }","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote_repository.rs#L243-L279","documentation":"When updating an existing global-configuration checkout (`update` mode), mise requires the destination's current branch to equal the branch of the repository being installed. `git symbolic-ref --short HEAD` in the destination is compared to the branch resolved from the transferred checkout; a mismatch aborts because a fast-forward across different branches is not possible.","triggerScenarios":"install/install_source/preview_source (install_at) with update enabled where the destination is checked out on a different branch than the transferred repository's HEAD branch (e.g. destination on `main`, transfer on `master` or a feature branch).","commonSituations":"The source repo renamed its default branch (`master`→`main`) or switched branches; the destination was left on an old/experimental branch; different machines onboarded at different times when the default branch differed.","solutions":["Switch the destination to the transferred branch: `git -C <destination> checkout <branch>`.","If the source branch was renamed, update the destination's remote-tracking ref and checkout the new branch, then retry.","Align branch conventions across machines so the transferred branch matches the checked-out branch everywhere.","Retry the install after the destination's HEAD branch matches."],"exampleFix":"// before\n$ git -C ~/.config/mise symbolic-ref --short HEAD\nmaster\n// transfer branch is main\n\n// after\n$ git -C ~/.config/mise checkout main","handlingStrategy":"validation","validationCode":"const branch = execSync(`git -C ${dest} symbolic-ref --short HEAD`).toString().trim();\nif (branch !== expectedBranch) throw new Error(`checkout ${expectedBranch} in ${dest} (currently ${branch})`);","typeGuard":null,"tryCatchPattern":"try {\n  await installSource(bundle, origin, { update: true });\n} catch (e) {\n  if (/branch differs/.test(String(e.cause ?? e))) {\n    execSync(`git -C ${dest} checkout ${expectedBranch}`);\n    return installSource(bundle, origin, { update: true });\n  }\n  throw e;\n}","preventionTips":["Keep all machines on the same default branch of the config repo","When renaming the default branch, update every checkout (git branch -m + remote tracking)","Avoid leaving the config checkout on feature branches; do branch work in clones"],"tags":["git","branch-mismatch","configuration","update"],"backgroundTag":"invalid-state-transition","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}