[Solved] error: src refspec main does not match

When you first try and push to a git repository, you may get the following error message:

error: src refspec main does not match any error: failed to push some refs to
Code language: Bash (bash)

This is because you have not committed your files!

How to fix this error

git commit -m "initial commit" git push origin main
Code language: Bash (bash)

The above code will commit your files that are staged, before pushing them to your desired branch.

By default, we push our code to the main branch above. Swap this out with another branch if you need.

Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments