Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nacha's avatar
Level 2

error: src refspec master does not match any

I did that

git init 
git add . 
git commit -m "initial commit" 

git remote add origin https://github.com/d/site.git

git push -u origin master

error

git push -u origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/d/site.git'

and thank you

0 likes
3 replies
Sergiu17's avatar

do you have any files in your folder?

run

git log

check if you have some commits, if not, then add a file or something, and start from git add ., then commit, then push

nacha's avatar
Level 2

thank you @sergiu17 if I type

git log
fatal: your current branch 'main' does not have any commits yet

and I follow what you said but it still the same error

automica's avatar
automica
Best Answer
Level 54

do you have any branches set up on your remote? you may find that you have a remote branch called main and are trying to push up master (which doesnt exist).

i would empty your local directory, checkout your remote branch, add your files and push up that way.

Please or to participate in this conversation.