刚才git push到远端时报错如下:
remote: Hint: To automatically insert Change-Id, install the hook:
remote: scp -p -P 29418 gerrit@127.0.0.1:hooks/commit-msg `git rev-parse --git-dir`/hooks/commit-msg
remote: git commit --amend
remote: ERROR: missing Change-Id in commit message footer
! [remote rejected] 本地分支名 -> refs/for/远端分支名 (missing Change-Id in commit message footer)
error: failed to push some refs to 'ssh://xxxxx'
git log,git show都显示是对的,但push就是失败,尝试如下三种方法皆无效且报错不变:
一.
按照提示运行
先$scp -p -P 29418 gerrit@127.0.0.1:hooks/commit-msg `git rev-parse --git-dir`/hooks/commit-msg
然后$git commit --amend
依旧push失败
二.
git commit --amend 然后删除Change-id那一行,让系统自动生成
依旧push失败
三.
git reset
然后重新提交
依旧失败
思路:使之等效为另一个问题"如何在本地分支bb上,使用本地分支aa的commit"
解决方法如下:
设之前操作的是分支aa
git checkout aa 切换到commit成功但是push失败的那个分支
git log 记录下commit id [如commit 7279dd1533ae68e5798f495334e9c07d148102cc]
git checkout bb 切换至bb分支
git log (非必需)
git cherry-pick 7279dd1533ae68e5798f495334e9c07d148102cc
git show (非必需)
git branch -a
git push letv bb:refs/for/远端分支名
成功