Fix · GitHub and Git
fatal: refusing to merge unrelated histories
What you may see
- My first pull fails after I created the repository with a README on GitHub
Most likely cause
The folder on your computer and the repository on GitHub started separately, so Git sees no common starting point.
Check first (about two minutes)
- Open the repository on GitHub: does it hold only a README or licence made at creation?
The fix prompt
What you type here never leaves your browser. The search runs on this page, and nothing is sent to a server or to an AI.
Kept only in this browser, on this device. Keys and passwords are removed before anything is saved.
Prompt language
Paste it into Claude, ChatGPT, Gemini or Cursor, then follow what it says.
After you tried it, did it work?
Steps
- Run git log --oneline on my computer and show what is on GitHub (git fetch then git log origin/main --oneline).
- If GitHub only has a README, merge deliberately: git pull origin main --allow-unrelated-histories, resolve conflicts with me, and then push.
- If GitHub holds real work, stop and ask me before merging.
Do not do this
- Do not delete the GitHub repository just to start clean if it holds anything.
- Do not force push to replace what is on GitHub.