已经git add,git commit后,在git push提交代码时出现报错如下,主要原因是缺少Change ID,可以参照提醒gitdir=$(git rev-parse --git-dir); scp -p -P 29418 uluxy181@10.118.234.22:hooks/commit-msg ${gitdir}/hooks/,试着加上ID。
不过本人的开发环境试了,无效。

Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 89.83 KiB | 0 bytes/s, done.
Total 5 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2)
remote: Processing changes: refs: 1, done    
remote: ERROR: commit c9e0a5b: missing Change-Id in message footer
remote: 
remote: Hint: to automatically insert a Change-Id, install the hook:
remote:   gitdir=$(git rev-parse --git-dir); scp -p -P 29418 uluxy181@10.118.234.22:hooks/commit-msg ${gitdir}/hooks/
remote: and then amend the commit:
remote:   git commit --amend --no-edit
remote: Finally, push your changes again
remote: 
To ssh://uluxy181@10.118.234.22:29418/MTK_Android/vendor/yfve/mt2712_saic_touchbar/packages
 ! [remote rejected] HEAD -> refs/for/saic_touchbar (commit c9e0a5b: missing Change-Id in message footer)
error: failed to push some refs to 'ssh://uluxy181@10.118.234.22:29418/MTK_Android/vendor/yfve/mt2712_saic_touchbar/packages'

本人解决办法:
1,到.git仓库下,打开COMMIT_EDITMSG文件,里面确实没有生成Change ID

uluxy181@ubuntu16-010:~/workspace1/touchbar/vendor/yfve/mt2712_saic_touchbar/packages/.git$ ls
COMMIT_EDITMSG  config  description  HEAD  hooks  index  info  logs  MERGE_RR  objects  packed-refs  refs  rr-cache  svn

2,cd到.git/hooks目录,发现commit-msg文件报红,应该是文件丢失

uluxy181@ubuntu16-010:~/workspace1/touchbar/vendor/yfve/mt2712_saic_touchbar/packages/.git/hooks$ ls
applypatch-msg.sample  commit-msg.sample   pre-applypatch.sample  pre-commit.sample          pre-push.sample    update.sample
commit-msg             post-update.sample  pre-auto-gc            prepare-commit-msg.sample  pre-rebase.sample

3,回退刚才git add 和git commit 提交的代码

git reset --soft HEAD^
git reset HEAD .

4,手动删除commit-msg文件,然后重新repo sync

uluxy181@ubuntu16-010:~/workspace1/touchbar/vendor/yfve/mt2712_saic_touchbar/packages$ rm -rf commit-msg

uluxy181@ubuntu16-010:~/workspace1/touchbar/vendor/yfve/mt2712_saic_touchbar/packages$ repo sync

5,这时候重新查看commit-msg文件状态

6,重新提交代码既可

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐