Git:git push -u origin origin:master

10 浏览
0 Comments

Git:git push -u origin origin:master

所以我有一个标题中列出的问题。

我想只使用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 anysrc 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)

0
0 Comments

问题:Git: git push -u origin origin:master出现的原因以及解决方法

当执行git branch -avv命令时,可以得到以下输出:

  • 你没有一个名为master的本地分支
  • 你有一个与origin同名的分支(这是一个指向上游仓库的远程分支)

这意味着你应该:

是的,我测试了你的解决方案,它起到了作用。谢谢!

0