What this thread does
Do first: check git remote get-url origin and git merge-base HEAD origin/main before deciding whether the histories should be joined.
Short answer
As of November 2026, Git 2.56.1 is available (November 10 maintainer release). fatal: refusing to merge unrelated histories is a safeguard: merge requires a common ancestor unless explicitly overridden. Use the git merge option --allow-unrelated-histories and pause with --no-commit only for an intentional union of independently started projects (merge). origin/main is an example; select the actual intended branch. The Git 2.9 release notes describe the default refusal and the opt-in flag (release notes).
Choose / don't choose
- Intentional independent roots: choose the opt-in merge when both histories belong in one project; don't use the flag solely to silence an unexpected failure.
- Wrong remote/branch: correct the selection and fetch the intended history; don't combine a mistaken repository with the current one (remote, fetch).
- Incomplete history: fetch the missing ancestry first. For an actually shallow clone,
--unshallowconverts a shallow repository to a complete one when the source is complete; absence of a base in a truncated graph is not proof of independent roots (fetch).
Not for: recovering commits after a reset or wrong-branch commit; see committed-to-main-by-mistake-move-it-or-revert-depending-on-push.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
git remote get-url | Retrieves URLs for the named remote; confirm repository identity, then choose the intended remote-tracking branch | Current Git docs | remote |
git merge-base | HEAD origin/main asks for their common ancestor; inspect failures/missing refs rather than treating all empty output alike | Current Git docs | merge-base |
--allow-unrelated-histories | Explicitly permit independent roots; no global configuration makes this the default | Git 2.9 release notes | release boundary, merge |
--no-commit | Stop before creating the merge commit for inspection; does not stop fast-forward updates | Current Git docs | merge |
git diff --cached | Inspect staged changes against HEAD before committing | Current Git docs | diff |
Order of operations
1. Preserve local changes before merging. Confirm remote URL, fetch the intended repository, and run git merge-base on the actual two tips. Review whether missing ancestry is deliberate, incomplete, or simply the wrong selection (remote, fetch, merge-base). 2. For deliberate independent roots, run the opt-in merge with --no-commit. Unrelated roots cannot fast-forward; for a general review-before-update workflow, the manual documents adding --no-ff to prevent a fast-forward bypassing the pause (merge). 3. Resolve overlapping-file conflicts by editing the intended result, then git add the resolved files to the index. Inspect git status and git diff --cached, then perform the project's acceptance checks (merge conflict instructions, status, diff). 4. Create the merge commit with git commit or git merge --continue. To abandon the attempt, use git merge --abort; pre-existing uncommitted edits can make restoration incomplete, which is why the clean starting point matters (merge).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
refusing to merge unrelated histories | No common ancestor in the available histories | Correct mistaken branch/remote/history depth first; opt in only for an intended union | merge, Shubham Chaudhary's report |
Automatic merge failed; fix conflicts and then commit the result. | File changes cannot be combined automatically | Resolve, git add the resolutions, inspect, then commit/continue | reset manual's conflict transcript, merge |
Missing
- The historical report occurred during a rebase, but the flag documented here belongs to
git merge. No rebase-specific flag equivalence is claimed.
Checked
2026-11-12; Git 2.56.1 release announcement, 2.9.0 release boundary, current merge/merge-base/remote/fetch/diff/status/reset references and Chaudhary's dated report read. No fetch or merge commands executed.
Started from a post by @Git project, packaged by the editor. Original post