{"record":{"id":"368b9013a4061fcf","repo":"jdx/mise","slug":"forced-publication-is-not-supported","errorCode":null,"errorMessage":"forced publication is not supported","messagePattern":"forced publication is not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/sync/network.rs","lineNumber":250,"sourceCode":"    pub(crate) fn push(\n        &self,\n        refspecs: &[String],\n        lease: Option<(&str, Option<&str>)>,\n    ) -> Result<PushOutcome> {\n        validate_url(&self.url)?;\n        let mut args = vec![\"push\".to_string(), \"--quiet\".to_string()];\n        if let Some((branch, expected)) = lease {\n            let name = format!(\"refs/heads/{branch}\");\n            let refs = self.ls_remote()?;\n            let observed = refs.iter().find(|(_, candidate)| candidate == &name);\n            if observed.map(|(oid, _)| oid.as_str()) != expected {\n                return Ok(PushOutcome::Rejected(\n                    \"the origin branch changed; fetch and reconcile before pushing\".into(),\n                ));\n            }\n        }\n        if refspecs.iter().any(|refspec| refspec.starts_with('+')) {\n            bail!(\"forced publication is not supported\");\n        }\n        args.push(\"--\".into());\n        args.push(self.url.clone());\n        args.extend(refspecs.iter().cloned());\n        let output = self.repo.network(args.iter().map(String::as_str))?;\n        if output.status.success() {\n            return Ok(PushOutcome::Done);\n        }\n        let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();\n        if stderr.contains(\"stale info\")\n            || stderr.contains(\"rejected\")\n            || stderr.contains(\"fetch first\")\n        {\n            return Ok(PushOutcome::Rejected(stderr));\n        }\n        Err(NetworkError(format!(\"pushing to {}: {stderr}\", self.url)).into())\n    }\n","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/history/sync/network.rs#L232-L268","documentation":"push refuses refspecs that begin with '+' (force-push). Force publication would overwrite history on the origin branch, which this history-sync code forbids by design; when the remote branch moved, the caller is told to fetch and reconcile instead.","triggerScenarios":"Calling push with any refspec string starting with '+', e.g. '+main:main' or '+refs/heads/*:refs/heads/*', on the history sync network transport.","commonSituations":"A developer habitually adds '+' to 'make sure' the push lands; a rebased/rewritten local history makes plain push fail and the user reaches for force-push; automation templates carry force refspecs.","solutions":["Remove the leading '+' from the refspec and push normally.","When push is rejected because the origin branch changed, fetch and reconcile (rebase/merge) locally, then push again.","If history truly must be rewritten on origin, do it outside this API with plain git push --force, acknowledging the history-sync store does not support it."],"exampleFix":"// before\nlet outcome = remote.push(&[\"+main:main\"])?;\n// after\nlet outcome = remote.push(&[\"main:main\"])?; // fetch + reconcile if rejected","handlingStrategy":"validation","validationCode":"let force = refspecs.iter().any(|r| r.starts_with('+'));\nif force { eprintln!(\"drop the leading '+' — forced publication is not supported\"); }","typeGuard":null,"tryCatchPattern":"match remote.push(&refspecs) {\n    Err(e) if e.to_string().contains(\"forced publication\") => {\n        // rebuild refspecs without '+' and reconcile first\n    }\n    other => other?,\n}","preventionTips":["Never prefix refspecs with '+' when writing to history-sync stores.","On PushOutcome::Rejected, fetch and reconcile instead of forcing.","Review automation templates for legacy force-push flags.","Keep local history linear with the origin to avoid the temptation to force."],"tags":["git","push","refspec","force-push"],"backgroundTag":"unsupported-operation","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}