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

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'

当前回答

我认为问题源于添加和提交node_modules文件夹。

使用git add.时。,您可能会得到无限滚动,就像它添加了几个文件一样。如果是这样,您不仅要添加脚本,还要添加大小较大的node_modules文件夹。

最好的解决方案是创建一个.gitignore文件,在其中粘贴#dependencies/node_modules。

现在,当您添加文件时,Git将忽略node_modules文件夹。

其他回答

 sudo git push -v --progress "origin" : origin/prod_18aug2022

当我从本地分支机构推到远程分支机构时,这对我很有用。

对于Windows上Cmder中Bash的用户,请确保在新的主目录中创建一个新的.ssh文件夹。

转到主目录cd~。生成ssh密钥ssh-keygen。保持所有输入为空(保持按回车键)将id_rsa.pub文件复制到Github>设置>SSH密钥

首先,gitadd。第二,gitcommit-m“message”第三,git推送原点分支

请检查拼写错误,因为这也可能导致错误。

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

*** 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

这只是意味着你忘了做初始提交,试试

git add .
git commit -m 'initial commit'
git push origin master