jdx/mise · error
local and origin histories are unrelated; use a fresh setup…
Error message
local and origin histories are unrelated; use a fresh setup store to adopt origin, or reconcile the repositories explicitly with Git. Neither history was replaced
What it means
`read` in the sync graph module fails when both the local history ref and the origin (upstream) ref exist but share no merge base — the two commit histories are completely unrelated. Adopting or publishing would silently discard one side's history, so the operation aborts leaving both histories intact.
Solutions
- Start from a fresh setup store to adopt the origin history (discarding local history after backing up files).
- Reconcile manually with Git: graft or merge the histories explicitly, then update both refs.
- Point the upstream ref at the correct remote that shares ancestry with the local history.
Defensive patterns
Strategy: validation
Validate before calling
const local = await git.revParse(HISTORY_REF);
const remote = await git.revParse(UPSTREAM_REF);
if (local && remote && (await git.mergeBase(local, remote)) === null) {
throw new Error("local and origin histories are unrelated; reconcile explicitly");
} Type guard
function historiesAreRelated(bases: string[]): boolean {
return bases.length > 0;
} Try / catch
try {
await sync.pull();
} catch (e) {
if (/histories are unrelated/.test(String(e))) {
// prompt the user: adopt origin fresh or reconcile manually
} else throw e;
} Prevention
- Never re-initialize a setup store that shares an origin with other machines.
- Clone the existing setup store instead of creating a fresh one.
- Verify the upstream ref points at the intended shared remote before syncing.
When it happens
Trigger: Calling `read` when `merge_bases(local, remote)` returns empty: two independently initialized setup stores were pushed/fetched to the same origin, or a remote was replaced with a fresh history.
Common situations: Re-initializing the setup store on one machine and pushing it; cloning a different store into a repo whose local history already exists; switching between distinct setup store remotes.
Related errors
- checked by the caller
- enrollment conflict in
- history changed during the operation; cannot replace its…
- is not in either snapshot
- path is not in either snapshot
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/05d79a73808c8870.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/history/sync/graph.rs:31
pub base: Option<String>,
}
#[derive(Debug)]
pub(crate) struct Candidate {
pub commit: String,
expected_local: Option<String>,
expected_remote: Option<String>,
}
impl Heads {
pub(crate) fn read(repo: &HistoryRepo) -> Result<Self> {
let local = repo.ref_oid(HistoryRepo::HISTORY_REF)?;
let remote = repo.ref_oid(UPSTREAM_REF)?;
let base = match (&local, &remote) {
(Some(local), Some(remote)) => {
let bases = repo.merge_bases(local, remote)?;
if bases.is_empty() {
bail!(
"local and origin histories are unrelated; use a fresh setup store to adopt origin, or reconcile the repositories explicitly with Git. Neither history was replaced"
);
}
// A criss-cross merge has shared ancestry but no unique base.
// It needs a merge commit, never an arbitrary fast-forward.
(bases.len() == 1).then(|| bases[0].clone())
}
_ => None,
};
Ok(Self {
local,
remote,
base,
})
}
/// Preparing a candidate does not advance a branch or write live files.
/// The caller must finish its complete application before adopting it.View on GitHub (pinned to 533346cc37)