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.
我以为有人在我之前推到了remoteecoes 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上
所以我发现有两个问题很难回答:
正如您在错误消息中看到的:
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中添加的)。谢谢大家,请将我对吸血鬼的评论作为一个蹩脚的借口。没问题,但请阅读并遵守;-)