Common mistake when creating new git repo. Error: src refspec master does not match any.

Creating new git repo and pushing it to remote server is fairly easy.

mkdir my-project
cd my-project
git init

You can work with project localy. When you want to push it to remote server, then it is necessary to add remote repo url.

git remote add origin <MY-URL>

Now you can push it:

git push -u origin master

When it works. Hooray. Sometimes you may find following error:

error: src refspec master does not match any.
error: failed to push some refs to '<MY-URL>'

The reason why this happens is not that obvious. :-)

Git creates master branch only after commit to your local repo. If you just initialize repo then there is no master. How to fix it?

Just add and commit at least one change to your repo and re-run push command. You can add e.g. .gitignore.

You can find more info at StackOverflow.

1. December 2012 at 9:09 - Software engineering (Tags: , , ). Both comments and pings are currently closed.

11 Responses to “Common mistake when creating new git repo. Error: src refspec master does not match any.”