Git: fatal: refusing to merge unrelated histories
The two branches have no common ancestor — typically a local repo and a remote that were both initialized separately.
Seen on:
Git
Meaning
Common when you git init locally and create the GitHub repo with a README/license, then try to pull.
Common causes
- Remote created with initial commit (README) and local repo initialized separately
- Wrong remote URL
- Shallow clone issues
⚡ Quick fix
- If intended:
git pull origin main --allow-unrelated-histories - Resolve conflicts (usually README), commit, push
- Double-check the remote URL first
Detailed fix by platform
Git
git remote -vto confirm you’re pulling the repo you think you are.
How to diagnose
- Remote — Correct repository?
- Intent — Do you really want to combine these histories?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026