Common causes
- The branch is named 'main' locally but you typed 'master' (or vice versa)
- You haven't made any commits yet, so the branch doesn't exist as a ref
- There's a typo in the branch name you specified
- You're pushing before making the first commit on a new repo
How to fix it
- Check what local branches exist: git branch
- Push using the correct branch name: git push origin main
- If no commits yet, make the first commit before pushing: git add . && git commit -m 'Initial commit'
- Rename your branch if needed: git branch -m old-name new-name
Example
error: src refspec main does not match any
error: failed to push some refs to 'origin'Running git push origin main on a new repo that has commits on 'master' instead of 'main'
Have a different error?
Paste any error message into the Error Translator to get an instant explanation.
