Cross-posting from my Medium entry.
Medium: Arisa F
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üß.
Top comments (10)
thanks for this but it has failed to work out for me
Didn't do anything for me either.
Did you get a solution?
Thank you so much! This worked for me
Happy to be your help!
Thanks. This worked for me
O man you save my time, Your this statement "Just add and commit something change to your repo, like adding .gitignore or any changes.Then re-run push command", solve my problem.
It's an old post but still glad to know it helped you!👍
Thank you! Saved my life. xD
Thanks bro, very helpful.