Src refspec master does not match any error when pushing to repository

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Server, Data Center, and Cloud By Request - This article was written for the Atlassian server and data center platforms but may also be useful for Atlassian Cloud customers. If completing instructions in this article would help you, please contact Atlassian Support and mention it.

Problem

When pushing a new repository to Bitbucket Server, the following error is returned from the Git client:

git push -u origin master

error: src refspec master does not match any.
error: failed to push some refs to 'http://stash.company.com/scm/PROJECT/REPO.git'

Cause

This is caused by the repository still being empty. There are no commits in the repository and thus no master branch to push to the server.

Resolution

Create the first commit inside of the repository and then it can be pushed. For example, the following with create an initial commit and push it to the server.

touch initial

git add initial

git commit -m "initial commit"

git push -u origin master
Last modified on Mar 30, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.