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

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'

当前回答

我面临着同样的问题,并尝试了这里的大多数答案,但问题是因为最近Github重命名的变化。

GitHub正在逐步将存储库的默认分支从master重命名为main。

https://github.com/github/renaming

您的新命令将是:

git push origin main

而不是:

git push origin master

其他回答

我也遇到了同样的问题,并且发现我没有提交任何文件,所以当我再次尝试提交时,我收到了以下错误消息:

*** Please tell me who you are.

Run

 git config --global user.email "you@example.com"
 git config --global user.name "Your Name"

 to set your account's default identity.
 Omit --global to set the identity only in this repository.

 fatal: unable to auto-detect email address (got 'USER@WINDOWS-HE6I2CL.(none)')

然后我所做的就是在全球范围内添加我的电子邮件和姓名,然后再次提交:

git commit -m 'Initial commit'

然后按下

git push -u origin master

同时检查是否更改了分支名称

对我来说,我已经将分支名称从添加状态条件更改为添加状态条件,但没有注意到末尾缺少的s。正确重命名了分支,git推送原点添加了状态条件-f。

这对我有用。

当您试图将空回购推送到git服务器时,会发生此错误。这可以通过初始化README.md文件来缓解:

cat > README.md

然后键入一些内容,然后输入一个回车键,然后按CTRL+D保存。然后是通常的提交步骤:

git add .
git commit -m "Initial commit"
git push origin master

我想这可能会对某人有所帮助。我今天做出了我的第一次重大承诺。我试了很多指南,但总是出错。

首先:将文件cd到目录中初始化git:gitinit提交文件:gitcommit要在有任何模糊的bash命令时强制提交,请单击I插入提交消息要继续:单击Esc

要发送到GitHub存储库,请首先确保已添加用户名和电子邮件:

git config --global user.name 'Your name'
git config --global user.email 'name@mail.com'

继续:

git remote add origin https://github repo url

要推送到存储库:

git push -u origin 'https://github.repo url'

它将提交加载到存储库中。

完成!!!

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