Back

Explore Courses Blog Tutorials Interview Questions
+4 votes
2 views
in DevOps and Agile by (29.3k points)
edited by

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'

closed

2 Answers

+5 votes
by (50.2k points)
edited by
 
Best answer

According to the question you’ve created a repository and created files in the index but you didn’t stage the file for that:

git add <file-name>

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.

For better understanding about these git commands go through the following crash course on git that will help you to understand git well

 You can also read the Git Tutorial and enroll for Git Training to learn in-depth about git.

by (29.3k points)
yes, after stagging all files it worked to me. thanks!
+4 votes
by (32.3k points)

You can do this:

1. Just simply try git show-ref to see what refs do you have. Is there refs/heads/master?

2. You can try git push origin HEAD:master as a more local-reference-independent solution. Now, this explicitly states that you want to push the local ref HEAD to the remote ref master (see the git-push refspec documentation).

Browse Categories

...