我有一个与标题相关的问题。
我想只使用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](https://istack.dev59.com/Q6oer.webp)
总之,我该怎么做才能正确地使用
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