unrelated histories 🌿 Git

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

  1. If intended: git pull origin main --allow-unrelated-histories
  2. Resolve conflicts (usually README), commit, push
  3. Double-check the remote URL first

Detailed fix by platform

Git

  1. git remote -v to confirm you’re pulling the repo you think you are.

How to diagnose

  1. Remote — Correct repository?
  2. 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.