Git:git push -u origin origin:master

mar*_*kin 7 git version-control github

所以我在标题中列出了问题.

我想用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'
Run Code Online (Sandbox Code Playgroud)

我搜索了这个问题(git:错误:src refspec master不匹配,src refspec master在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
Run Code Online (Sandbox Code Playgroud)

这是github图的网络窗口: my_project分支

所以总结起来-我应该怎么做才能正常使用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
Run Code Online (Sandbox Code Playgroud)

$ git remote -v

origin  https://github.com/myprofile/my_project.git (fetch)
origin  https://github.com/myprofile/my_project.git (push)
Run Code Online (Sandbox Code Playgroud)

Von*_*onC 5

考虑到的输出git branch -avv:

  • 你没有一个名为的本地分支master,
  • 你有一个与origin(与远程引用上游仓库)相同名称的分支.

这意味着你应该: