Menu

7 Git errors that stop beginners cold (and the one-line fix for each)
πŸ“°

7 Git errors that stop beginners cold (and the one-line fix for each)

DEV Community: beginnersΒ·HollisΒ·17 days ago
#TFZjGSeX
#devtobeginners#devto#dev#enter#exit
Reading 0:00
15s threshold

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.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.