为什么git push失败?错误:无法将一些参照推送到

时间:2019-12-24 16:12:53

标签: git github

我的上一步是

git remote set-url origin https://github.com/MilenkoM/ex1microhydra.git

git remote -v 

显示

origin  https://github.com/MilenkoM/ex1microhydra.git (fetch)
origin  https://github.com/MilenkoM/ex1microhydra.git (push)

如果我去

git push origin master

然后我出错了

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

为什么? Git日志显示

commit 0e9a31ff7c1fb1d0bb56e8ad5a359f92666be6a9 (HEAD -> mybranch)
Date:   Wed Dec 18 17:12:21 2019 +0100

     Changes to be committed:
            new file:   index.js
            new file:   package.json

我遵循了Loi和eftshift的建议,并尝试了

git checkout master

Switched to branch 'master'

它也不起作用

git push origin mybranch:master

To https://github.com/MilenkoM/ex1microhydra.git
 ! [rejected]        mybranch -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/MilenkoM/ex1microhydra.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我是git新手,这些快进是什么?

 git show-ref
8ef0e288bb2ab7c42ebc37b018fcb08a73073c2e refs/heads/master
0e9a31ff7c1fb1d0bb56e8ad5a359f92666be6a9 refs/heads/mybranch
097e48b3fd8f87f90f19872fc788ea2f0bb433cc refs/remotes/origin/master

我应该去拉,但是拉什么?

1 个答案:

答案 0 :(得分:1)

您好像没有一个名为 master 的本地分支。如果您想将您的 mybrancy 分支推送到远程主服务器,则可以这样操作:

git push origin mybranch:master