Help, I get “refusing to merge unrelated histories”
Your local repository and the remote started separately, typically with a README created on GitHub. Join them once.
git pull --no-rebase origin main fatal: refusing to merge unrelated histories
The fix
git pull --no-rebase origin main --allow-unrelated-historiesMerges the remote history, often just a README, into yours.
--no-rebasemakes it a merge no matter how pull is configured.git push -u origin mainPushes the combined history and links main to origin/main.
Before
After
Why this works
The two histories share no common commit, so Git refuses to merge them by default to protect you from combining two unrelated projects by mistake. When they really are the same project, the flag allows the merge once. If both sides have a file with the same name, such as README.md, resolve that conflict like any other.