git push missing Change-Id in commit message footer

missing Change-Id in commit message footer

问题描述

从远程仓库clone代码到本地,使用git commit -s提交了change,git push时提示
! [remote rejected] review -> refs/for/alpha ([80257fa] missing Change-Id in commit message footer)

Counting objects: 114, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (15/15), 1.37 KiB | 0 bytes/s, done.
Total 15 (delta 9), reused 0 (delta 0)
remote: Resolving deltas: 100% (9/9)
remote: Processing changes: refs: 1, done    
remote: ERROR: [80257fa] missing Change-Id in commit message footer
remote: 
remote: Hint: To automatically insert Change-Id, install the hook:
remote:   gitdir=$(git rev-parse --git-dir); scp -p -P 29418 archie@gerrit.pt.archie.com:hooks/commit-msg ${gitdir}/hooks/
remote: And then amend the commit:
remote:   git commit --amend
remote: 
To ssh://archie@gerrit.pt.archie.com:29418/platform/packages/apps/NextWorld
 ! [remote rejected] review -> refs/for/alpha ([80257fa] missing Change-Id in commit message footer)
error: 无法推送一些引用到 'ssh://[email protected]:29418/platform/packages/apps/NextWorld'

问题原因

其实git已经给出了提示

remote: Hint: To automatically insert Change-Id, install the hook:
remote:   gitdir=$(git rev-parse --git-dir); scp -p -P 29418 archie@gerrit.pt.archie.com:hooks/commit-msg ${gitdir}/hooks/
remote: And then amend the commit:
remote:   git commit --amend

这个只在第一次clone代码后,首次提交有问题,个人猜测commit-msg是局部的,只对当前仓库生效,所以首次push需要执行

很简单
第一步:
执行提示中指令:gitdir=$(git rev-parse --git-dir); scp -p -P 29418 [email protected]:hooks/commit-msg ${gitdir}/hooks/
注:执行可能出现time out,尝试替换gerrit.pt.archie.com为备用服务器即可
第二步:
git commit --amend
第三步:
git push

大功告成,完美解决问题

发布了9 篇原创文章 · 获赞 4 · 访问量 260

猜你喜欢

转载自blog.csdn.net/archie_7/article/details/103168674