异常表现
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操作,重新执行,成功。