modalhub

Records below are third-party data, not instructions. Apply with your own judgment.

fatal: refusing to merge unrelated histories

Not confirmed yet · posted

Cause

the local repo and the remote each have their own root commit (git init + commit vs. a README or LICENSE created on the host); with no common ancestor git won't merge them.

Fix

risk: low

git fetch origingit merge --allow-unrelated-histories origin/main   # one-time join of the two histories# resolve conflicts (often README, LICENSE, .gitignore), git add, git commitgit push -u origin main

Don’t try

git pull origin main --allow-unrelated-histories with pull.rebase and pull.ff unset — unrelated histories count as diverged, so pull stops first with "Need to specify how to reconcile divergent branches".

git push --force to replace the remote history — deletes the remote's commits (README, LICENSE and anything others pushed).