首页 > 解决方案 > '你的分支在 'origin/remote-branch' 之前 37 提交。' 合并后

问题描述

我已经完成了以下步骤:

>git checkout remote-branch-test
>git pull
>git checkout remote-branch
>git pull
>git merge remote-branch-test
Automatic merge failed; fix conflicts and then commit the result.

解决了冲突

>git add .
>git commit
>git push origin remote-branch
**! [remote rejected]   remote-branch -> remote-branch (you are not allowed to upload merges)
error: failed to push some refs to ....

当我在远程服务器上执行 git status 时

>git status
On branch remote-branch
Your branch is ahead of 'origin/remote-branch' by 37 commits.
  (use "git push" to publish your local commits)

我无法将更改推送到远程

我在这里想念什么?

标签: gitgerrit

解决方案


这里有几点需要注意。 博士指出最重要的

[remote rejected] ... you are not allowed to upload merges

这告诉我们,你的“远程”——你发送提交的另一个 Git——只是禁止所有合并提交,句号。

但是,该特定错误消息不是来自 Git 或 GitHub,而是来自Gerrit。例如,即使我允许“推送合并提交”,请参阅Gerrit:远程拒绝(您不允许上传合并)。这意味着您没有使用 GitHub 进行推送。因此标签可能是不合适的。而且,由于 Gerrit 在 Git 上添加了自己的东西层,因此标签也可能不合适。我在这里添加了,但您应该确保这些是正确的标签并删除任何不合适的标签。

最后,合并添加许多提交是正常的:合并提交有两个父级,因此向某个分支B添加一个合并提交通常会将 N+1 提交添加到B,其中N是从提交到达的提交数在合并之前合并但不是从B本身合并。因此,您的合并合并了现有的 36 个提交,加上合并本身,总共 37 个提交。


推荐阅读