+5 votes
1 view
in Devops and Agile by (25.5k 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'

2 Answers

+6 votes
by (42.7k 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 (25.5k points)
yes, after stagging all files it worked to me. thanks!
+5 votes
by (31.4k 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).

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...