Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git push说被拒绝但通过了_Git_Github - Fatal编程技术网

git push说被拒绝但通过了

git push说被拒绝但通过了,git,github,Git,Github,我有一个不同的问题,而不是通常在某个时候重写历史所造成的问题。让我给你看看 我在ecoes-poc分支上,比远程对应方提前一次提交: $ git log 917f264f 21 hours xxx (HEAD -> ecoes-poc) commit message b2a6ce0e 2 days xxx (origin/ecoes-poc) another commit message 在这一点上,我对上一次本地提交进行了修改,然后尝试推动: $ git push

我有一个不同的问题,而不是通常在某个时候重写历史所造成的问题。让我给你看看

我在
ecoes-poc
分支上,比远程对应方提前一次提交:

$ git log
917f264f  21 hours  xxx   (HEAD -> ecoes-poc) commit message
b2a6ce0e  2 days    xxx   (origin/ecoes-poc)  another commit message
在这一点上,我对上一次本地提交进行了修改,然后尝试推动:

$ git push
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (14/14), 1.85 KiB | 0 bytes/s, done.
Total 14 (delta 10), reused 0 (delta 0)
remote: Resolving deltas: 100% (10/10), completed with 9 local objects.
To some-repo.git
   b2a6ce0e..aba1574b  ecoes-poc -> ecoes-poc
 ! [rejected]          master -> master (non-fast-forward)
error: failed to push some refs to 'some-repo.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
我以为有人在我之前推到了remote
ecoes poc
,来到GitHub,惊讶地发现我的提交被拒绝了,而没有人推过任何东西。回到shell和git日志:

~ $ git log
a3bf26cc  21 hours  xxx   (HEAD -> ecoes-poc, origin/ecoes-poc) commit message
b2a6ce0e  2 days    xxx   another commit message
如图所示,
origin/ecoes
在提交git上,git刚刚说它被拒绝了,它也在GitHub上

所以我发现有两个问题很难回答:

  • 为什么一开始就被拒绝
  • 尽管git拒绝了推送,但提交最终是在origin/ecoes分支和GitHub上完成的

  • 正如您在错误消息中看到的:

    To some-repo.git
       b2a6ce0e..aba1574b  ecoes-poc -> ecoes-poc
     ! [rejected]          master -> master (non-fast-forward)
    
    推送至
    主机
    被拒绝,推送至
    ecoes poc
    成功。
    这不是一个全有或全无的问题,而是每个推送的参考,不管推送是否被拒绝,至少在您的情况下

    因此,
    ecoes-poc
    有您的推送,而
    master
    没有


    如果在没有任何附加参数的情况下调用
    git push
    ,则推送的内容由配置变量
    push.default
    定义。您可以在上阅读有关其值的信息。显然,您已将其设置为
    matching
    ,这是唯一会推送比当前分支(即所有名称匹配分支)更多的选项。如果不是,那么您可能会使用非常旧的Git版本,其中默认行为是
    匹配。在这种情况下,您可能应该更新Git。

    您同时推送了
    master
    ecoes-poc
    。只有
    master
    被拒绝。除了@NilsWerner所说的:由于您的报价显示
    git-push
    (不是
    git-push--all
    或一些类似的变体),您要么将
    push.default
    配置为
    匹配
    ,要么使用默认为
    匹配
    的2.0 git之前的版本。您可能应该升级Git和/或配置
    simple
    (请注意,如果您的Git真的很古老,您可能没有
    simple
    :它是在Git 1.7.11中添加的)。谢谢大家,请将我对吸血鬼的评论作为一个蹩脚的借口。没问题,但请阅读并遵守;-)