Git: git push -u origin origin:master

7

我有一个与标题相关的问题。

我想只使用git push -u origin master命令。

但是,如果输入此命令,我会收到以下错误消息:

error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/myprofile/my_project.git'

我对这个问题进行了搜索(git: error: src refspec master does not match any, src refspec master does not match any when pushing commits in git) - 但解决方案在我的情况下没有帮助。

看起来我只是忘记对原始远程分支进行一些初始提交,而是创建了另一个分支,然后使用了该分支。

这是git ls-remote的输出:

$ git ls-remote
From https://github.com/myprofile/my_project.git
152e795f054f6f756842bf61ee968ba3e5ee873d        HEAD
7d505dbf09585ecfbb239c2148337043b899cc13        refs/heads/add-mysql-repo
152e795f054f6f756842bf61ee968ba3e5ee873d        refs/heads/break-into-modules
e7905a3dacc9ea3e6c4c1f2dd9412f8deb692e30        refs/heads/master

这是Github图形化网络窗口: my_project branches
总之,我该怎么做才能正确地使用git push -u origin master,而不是git push -u origin origin:master
编辑: $ git branch -avv
  add-mysql-repo        7d505db add mysql case to switch
  break-into-modules    152e795 add gitignore
* origin                e7905a3 [origin/master] add methods for entities validation
  remotes/origin/master e7905a3 add methods for entities validation

$ git remote -v

origin  https://github.com/myprofile/my_project.git (fetch)
origin  https://github.com/myprofile/my_project.git (push)

git branch -avv 返回什么?而 git remote -v 呢? - VonC
@VonC 我在这些命令中添加了输出,请看一下。 - marknorkin
1个回答

5

考虑到 git branch -avv 的输出:

  • 您没有名为 master 的本地分支,
  • 您有一个与 origin 同名的分支(远程引用上游 repo)。

这意味着您应该:


是的,我测试了你的解决方案,它很有帮助。谢谢! - marknorkin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接