在Git中推送提交时出现消息“ src refspec master不匹配” [英] Message 'src refspec master does not match any' when pushing commits in Git

查看:56
本文介绍了在Git中推送提交时出现消息“ src refspec master不匹配”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下命令克隆我的存储库:

I clone my repository with:

git clone ssh://xxxxx/xx.git 

但是在我更改了某些文件并添加提交,我想将它们推送到服务器:

But after I change some files and add and commit them, I want to push them to the server:

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'


推荐答案

我遇到了同样的问题,并且我使用了-allow-empty

I faced the same problem, and I used --allow-empty:

$ git commit -m "initial commit" --allow-empty
...
$ git push
...



补充



主要原因之一问题是某些Git服务器(例如BitBucket)在克隆新存储库时没有初始化 master 分支。

这篇关于在Git中推送提交时出现消息“ src refspec master不匹配”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆