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

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

问题描述

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

git clone ssh://xxxxx/xx.git

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

git add xxx.phpgit commit -m "测试"git push origin master

但我返回的错误是:

错误:src refspec master 不匹配.错误:无法将一些引用推送到ssh://xxxxx.com/project.git"

解决方案

  1. 试试 git show-ref 看看你有什么引用.有 refs/heads/master 吗?

<块引用>

由于最近在 GitHub 中用 main 替换 master"操作,您可能会注意到有一个 refs/heads/main.因此,以下命令可能会从 git push origin HEAD:master 更改为 git push origin HEAD:main

  1. 您可以尝试 git push origin HEAD:master 作为更独立于本地引用的解决方案.这明确指出您要将本地引用 HEAD 推送到远程引用 master(请参阅 git-push refspec 文档).

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

But the error I get back is:

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

解决方案

  1. Try git show-ref to see what refs you have. Is there a refs/heads/master?

Due to the recent "Replacing master with main in GitHub" action, you may notice that there is a refs/heads/main. As a result, the following command may change from git push origin HEAD:master to git push origin HEAD:main

  1. You can try git push origin HEAD:master as a more local-reference-independent solution. This explicitly states that you want to push the local ref HEAD to the remote ref master (see the git-push refspec documentation).

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

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