You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Git推送到Gerrit时同时更新两个分支的问题求助

Git推送时意外触发多个Gerrit变更的解决方法

问题描述

执行git push origin HEAD:refs/for/main命令时,本地Git配置异常,导致变更被同时推送到Gerrit的两个变更(编号287913和290536),仅需推送到目标分支对应的290536变更,需排查并修复该问题。

远程推送反馈(翻译后)

remote:
remote: https://git.team.com/r/c/product/+/287913 [wip] CI work
remote:
remote: 以下审批已过期并被移除:
remote: * 由svc完成的Verified-1审批
remote:
remote: https://git.team.com/r/c/product/+/290536 [基础镜像层] 移植逻辑
remote:
remote: 以下审批已过期并被移除:
remote: * 由svc完成的Verified-1审批
remote:

解决步骤

1. 检查并修正本地推送配置

  • 查看全局Git推送相关配置:
    git config --global --get-regexp push
  • 查看当前仓库的本地推送配置:
    git config --local --get-regexp push

如果输出中存在指向287913或多余的推送规则(比如错误的remote.origin.push条目、push.default设置不符合需求),直接删除对应配置项:

  • 删除全局配置:git config --global --unset <配置键名>
  • 删除仓库本地配置:git config --local --unset <配置键名>

2. 强制指定单一推送目标(临时方案)

推送时明确添加参数,确保仅推送当前提交到目标分支的Gerrit变更:
git push origin HEAD:refs/for/main --no-follow-tags
--no-follow-tags参数可避免标签被意外推送关联到其他变更,保证推送目标唯一。

3. 清理误推送的Gerrit变更(可选)

如果287913是误触发的无效变更,可直接在Gerrit界面将其标记为废弃(Abandoned),避免后续混淆。

内容的提问来源于stack exchange,提问作者AhmFM

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 10:33:12