Git 错误 : src refspec master does not match any error: failed to push some refs

标签 git bitbucket git-push refspec

<分区>

我正在尝试将文件添加到我在 BitBucket 上的存储库中,但遇到了问题。

我正在使用 GIT,这是我输入的内容

$ cd lis4368/assignments
$ git remote
$ git remote -v
$ git remote rm origin

然后我输入这个(这是 BitBucket 告诉我输入的)

$ git remote add origin https://cpb09e@bitbucket.org/cpb09e/cpb09e.git
$ git push -u origin master

我不断收到此错误消息:

error: src refspec master does not match any.
error: failed to push some refs to 'https://cpb09e@bitbucket.org/cpb09e/cpb09e.git'

有人能帮帮我吗?我已经尝试了从 git commit 到 rm -rf * 的所有方法,但我根本无法工作。

最佳答案

此消息的一个典型根本原因是:

  • 当 repo 被初始化时(git init lis4368/assignments),
  • 从未做出任何 promise

即,如果您没有至少添加和提交一次,则不会有本地 master 分支可推送。

首先尝试创建一个提交:

  • 通过添加 (git add .) 然后 git commit -m "first commit"
    (假设您有合适的文件添加到索引中)
  • 或者通过创建第一个空提交:git commit --allow-empty -m "Initial empty commit"

然后再次尝试 git push -u origin master

有关更多信息,请参阅“Why do I need to explicitly push a new branch?”。

关于Git 错误 : src refspec master does not match any error: failed to push some refs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12452042/

相关文章:

git - 在子目录位于主 repo 与子模块化的分支之间切换

linux - Gobblin Git 克隆错误

git - Azure 分支 PR 策略 - 要求源分支是最新的

issue-tracking - 如何通过电子邮件将问题发送到 BitBucket?

android - 管道 : Minimum supported Gradle version is 4. 10.1。当前版本是 4.4

git - `git push` -- 没有输出,没有任何反应

git - 使用git发布到网站

git - 如何在 `git log` 中的每个提交中显示分支名称

mercurial - 协调多个依赖的 mercurial 存储库版本的推荐方法?

java - java 类的重命名如何影响 git 状态?