Most Git errors look scary but have a boring, one-command fix. Here are the seven I see people get stuck on most often, with the fix first and the explanation after.
1. error: src refspec main does not match any
git add . && git commit -m "Initial commit" git push -u origin main
Enter fullscreen mode
Exit fullscreen mode
You tried to push a branch that has no commits yet (or your branch is called master , not main ). Check with git branch . If it says master , either push that or rename it: git branch -M main .
2. fatal: refusing to merge unrelated histories
git pull origin main --allow-unrelated-histories
Enter fullscreen mode
Exit fullscreen mode
This usually happens when you created a repo on GitHub with a README and also ran git init locally. Two separate histories exist, and Git won't merge them unless you say so explicitly.
3.β¦