在Git中推送提交时出现消息“ src refspec master不匹配”

我用如下方法克隆个人存储库: php

git clone ssh://xxxxx/xx.git

可是,在我更改了一些文件并addcommit它们以后,我想将它们推送到服务器: git

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

可是我获得的错误是: github

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

#1楼

当您在特定分支中并尝试推入尚不存在的另外一个分支时,也会发生这种状况,例如: 服务器

$ git branch
* version-x  # you are in this branch
  version-y

$ git push -u origin master
error: src refspec master does not match any.
error: failed to push some refs to 'origin_address'

#2楼

若是是第一次使用它,则须要配置Git安装,它具备: ssh

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

git config --global user.name "Your Name"

#3楼

缺乏或跳过git add .git commit可能致使此错误: ide

git push -u origin master
Username for 'https://github.com': yourusername
Password for 'https://yourusername@github.com': 
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/yourusername/foobar.git'

要修复此问题,请从新初始化并遵循正确的顺序: this

git init
git add .
git commit -m 'message'
git *create remote
git push -u origin master

#4楼

  1. 个人更改已经提交
  2. 强制推送仍然给了我一样的错误。

因此我尝试了Vi的解决方案spa

git push origin HEAD:<remoteBranch>

这对我有用。 code


#5楼

若是您要推送的分支名称中有错字,也会发生这种状况。 rem

相关文章
相关标签/搜索