我使用以下内容克隆存储库:

git clone ssh://xxxxx/xx.git 

但在我更改一些文件并添加和提交它们之后,我想将它们推送到服务器:

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

但我得到的错误是:

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

当前回答

我也面临同样的问题。但我注意到,发生此错误时,我的目录是空的。当我创建了一个示例文件并再次推送时,它起了作用。因此,在推送之前,请确保您的文件夹不是空的!!

其他回答

git push-u原始主机

error: src refspec master does not match any.
error: failed to push some refs to 'http://REPO.git'

这是由于存储库仍然是空的。存储库中没有提交,因此没有主分支可以推送到服务器。

这对我有用

决议

1) git init
2)git commit -m "first commit"
3)git add app
4)git commit -m "first commit"
5)git push -u origin master

当您添加了文件,忘记提交和推送时,就会发生这种情况。所以提交文件,然后推送。

如果要在原点远程创建新分支,则需要首先在本地创建相同的分支:

$ git clone -b new-branch
$ git push origin new-branch

试试看:

git add .

git commit -m "your commit message"

git remote add origin *remote repository URL*

git push origin *your-branch-name*

我有一个非常长的本地分行名称。

git branch -m new_shorter_branch_name

解决了问题。