idea使用gerrit提交报错:missing Change-Id in commit message footer

本文介绍了一种在使用Gerrit进行代码审查时遇到的常见错误:推送时因提交消息缺少Change-Id而被拒绝,并提供了详细的解决步骤,包括如何安装commit-msg钩子以自动插入Change-Id。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

异常表现

commit + push直接推送正常;
commit + push,勾选Push to Gerrit,报错。提示

remote: 
remote: Processing changes: refs: 1        
remote: Processing changes: refs: 1, done            
remote: ERROR: missing Change-Id in commit message footer        
remote: Suggestion for commit message:        
remote: [add]: 新增返回枚举类型        
remote: 
remote: Change-Id: Ifcd166f864160ffb73d22d3259938ba915928bb5        
remote: 
remote: Hint: To automatically insert Change-Id, install the hook:        
remote:   gitdir=$(git rev-parse --git-dir); scp -p -P 29418 ***@***:hooks/commit-msg ${gitdir}/hooks/        
remote: 
remote: 
error: failed to push some refs to 'ssh://gerrit.***.com:29418/bank-record-provider'
To ssh://gerrit.***.com:29418/bank-record-provider
!	refs/heads/dev-2.7.0:refs/for/dev-2.7.0%r=***@***.com	[remote rejected] (missing Change-Id in commit message footer)
Done

原因是.git\hooks下少了文件:commit-msg

解决方法

根据提示到项目根目录下直接执行ssh命令:
(ip+域名看一下是不是需要转换,我这边是需要的)

$  gitdir=$(git rev-parse --git-dir); scp -p -P 29418 ***@gerrit.***.com:hooks/commit-msg ${gitdir}/hooks/
subsystem request failed on channel 0
scp: Connection closed

报错了,百度搜了下:
https://blog.csdn.net/weixin_43163668/article/details/125880503
-p 改为 -O

$  gitdir=$(git rev-parse --git-dir); scp -O -P 29418 ***@gerrit.***.com:hooks/commit-msg ${gitdir}/hooks/
commit-msg                                          100% 4359   480.6KB/s   00:00

之后之后根目录会多出下面这个文件,此时回退commit操作,重新执行,成功。

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值