Git, Github: Git Initialize Error “error: src refspec master does not match any.”

Arisa F
2 min readFeb 28, 2019

--

Hi, it’s Arisa, a freelance Full Stack Developer living in Germany.

I’m sure you’re looking at this entry because you got an error in your terminal or PowerShell from Git.

I also got the error says,

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

Situation

The situation here is very basic.
Thought about to create a new repository in my Github.

I already had my project ready in my local and simply only needed to create a new repo, then push my project.

You should see in your Github repo page you just created like this.

It’s easy, just follow as it’s written in “…or create a new repository on the command line.”

Normally, it works and you’ll see README.md is added.
But if you’re unlucky, you’ll see an error like in above.

Solution

What to do?
It’s not a big deal.

Just add and commit something change to your repo, like adding .gitignore or any changes.
Then re-run push command.

Why does it work?

A trick behind here is starting to know this.
Git creates a master branch only after commit to your local repo.
If you just initialize repo then there is no master.

That’s why Git returns you an error says,

src refspec master does not match any.

Simple, right?
No more getting a heart attack from command errors.

Hope this entry helped you to work on your project.

Tschüß.

--

--

Arisa F
Arisa F

Written by Arisa F

Freelance Frontend & Full Stack Developer from Japan living in Germany. https://aiki-developer.com/ Podcast | https://anchor.fm/arisa_anonymous

No responses yet