Interview Prep/Git & GitHub/GitHub, Actions and Pull Request Issues

Opening a PR shows "There isn't anything to compare. main and import are entirely different commit histories." and locally `git merge` says `fatal: refusing to merge unrelated histories`.

IntermediateTroubleshootingGitHub, Actions and Pull Request Issues
Answer

Likely causes → The two branches share no common ancestor: someone ran git init and pushed a new history to the same repo, created the GitHub repo with a README and then pushed an existing local repo, or imported code with a tool that started fresh history.

Diagnose → git merge-base main import || echo "no common ancestor"

Fix → If you really want to combine them:

git switch import
git merge origin/main --allow-unrelated-histories
# resolve conflicts (often README/.gitignore), commit, push, open the PR

If the new history should simply replace the old one, rebase the import commits onto main instead.

Prevent → Create empty GitHub repos (no README/licence) when pushing existing code, or clone first and then add files.

All Git & GitHub questions Roadmap: Git & GitHub

More on GitHub, Actions and Pull Request Issues