Git Error
Fix "fatal: refusing to merge unrelated histories" in Git
Developer guide and instant terminal command to diagnose and solve this error.
Terminal Output
$fatal: refusing to merge unrelated histories
Why Does This Error Happen?
Git prevented a merge or pull because the local and remote repositories were initialized separately and do not share a common ancestor commit.
Instant Terminal One-Liner Fixes
Linux (Bash / Zsh)
git pull origin main --allow-unrelated-histories
macOS (Terminal / iTerm2)
git pull origin main --allow-unrelated-histories
Windows (PowerShell Run as Administrator)
git pull origin main --allow-unrelated-histories
Comprehensive Step-by-Step Resolution
- 1Add the "--allow-unrelated-histories" flag to git pull or git merge.
- 2Resolve any initial merge conflicts in README or LICENSE files.
- 3Commit and push the merged result.
Dedicated Companion Tool
Open ToolTroubleshoot using the Git Recipe & Command Solver
Use our client-side utility with zero server upload for instant debugging.
Frequently Asked Questions
Frequently Asked Questions
Frequently Asked Questions
Everything you need to know regarding specifications, syntax, and security best practices.
Git prevented a merge or pull because the local and remote repositories were initialized separately and do not share a common ancestor commit.