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

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文件夹。

其他回答

在我Git只添加了一个目录之后,我发现这发生在一个全新的存储库中。

一旦我添加了一个文件(例如README),Git推送就非常成功。

也许GitHub不知道你是谁。

首先,您必须运行:

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

如果它没有识别出您有一个主分支,只需创建它并再次提交。

要创建主分支,请执行以下操作:

git checkout -b master

这对我有用:

只需签出主分支:

git checkout -b master
git add .
git push origin master

或者使用——强制改变。

git push origin master --force

试试看:

git add .

git commit -m "your commit message"

git remote add origin *remote repository URL*

git push origin *your-branch-name*