Git Diagnostic

Fix Git "fatal: refusing to merge unrelated histories"

Git blocks merging two branches that do not share a common commit ancestor (common when initializing a local git repository and pulling from a GitHub repository initialized with a README).

fatal: refusing to merge unrelated histories

Quick Fix Checklist

  1. Run git pull with the override flag: git pull origin main --allow-unrelated-histories
  2. Resolve any merge conflicts in your editor (e.g. conflicting README.md or .gitignore)
  3. Stage and commit: git add . && git commit -m "Merge remote and local histories"
  4. Push your merged branch: git push -u origin main