The two branches share no common ancestor — GitHub-created repos with a seed commit vs your local repo, or a repo re-initialized from scratch. The escape hatch exists, but understand what you're joining first.
Creating a GitHub repo with 'Add a README' makes an initial commit your local repo never saw. Different roots = unrelated. The fix is one pull flag — or don't seed the remote next time.
Re-init (rm -rf .git; git init), a filtered/rewritten history, or importing from a tarball: the new root has no ancestor of the old one.
git log --oneline origin/main | tail -3; git log --oneline main | tail -3 # different root commits
git pull origin main --allow-unrelated-histories # resolve conflicts (likely the README), commit
git merge origin/main --allow-unrelated-histories -X ours # keep your versions on conflicts
# GitHub: leave 'Add a README' unchecked when you'll push an existing local repo
--allow-unrelated-histories doesn't rewrite anything — it just permits the merge. The result is one repo containing both root commits. If the 'unrelated' side has real divergent code you care about, review what you're merging: the flag bypasses a safety check, not a bug.
Yes — it merges both histories with both root commits preserved. It's refused by default because it usually indicates a mistake (wrong remote). Verify the remote is the right project first.
Only if the remote truly has nothing worth keeping (a lone seeded README). Force-push replaces the remote's commits — on shared repos, that deletes other people's history. When in doubt, merge instead.
Our most-documented failures, packaged as ready-to-ship starter kits: Docker, Kubernetes, and Terraform.
Browse the template store →One-time. Yours to modify. Instant download from the NinjaOps template store.
One short email when new fixes and production templates drop. No spam, unsubscribe anytime.
Spin up a cloud server in 60 seconds and reproduce this fix yourself — pay by the hour.
Sentry — Free tier: see the exact line of code that broke, before users report it.
We earn a commission if you buy through our links — it never costs you extra. More vetted tools on our picks hub · comparing clouds? DigitalOcean vs Vultr and vs AWS · full deals: DigitalOcean · Vultr · NordLayer · Semrush