Error: src refspec master does not match any when pushing commits in Git

2.7K    Asked by NatalieDowning in Devops , Asked on Jul 15, 2021

 I clone my repository with:

git clone ssh://xxxxx/xx.git 

But after I change some files and add and commit them, I want to push them to the server:

git add xxx.php
git commit -m "TEST"
git push origin master

But the error I get back is:

error: src refspec master does not match any.  
error: failed to push some refs to 'ssh://xxxxx.com/project.git'


Answered by Jasmine Forsyth

According to the question you’ve created a repository and created files in the index but you didn’t stage the file and getting error src refspec master does not match any.

For that use:

git add

Or

git add . //for adding all files

Then commit the files using:

git commit -m”initial commit”

Then your files will be saved to the local system and the error is resolved.



Your Answer

Interviews

Parent Categories