即使已经存在,Git push也会寻找Change id

时间:2018-01-23 13:54:17

标签: git

我提交了包含更改ID的消息(直接从gerrit结账到我的本地机器)。

commit bb4bfe6f068b4f21414610e28f9216ada2810310 (HEAD)
Author: xxxx<ccc.d.usman@ccc.com>
Date:   Thu Jan 18 12:11:55 2018 +0000

TORF-164239 ARE XYZ page to include extra columns

Change-Id: I6b79a8723acc629470582cfb8cac22495e282b4b

但是当我尝试推送时,它会告诉我所提交的消息不存在。

$ git push origin HEAD:refs/for/master
Counting objects: 533, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (292/292), done.
Writing objects: 100% (533/533), 55.17 KiB | 1.62 MiB/s, done.
Total 533 (delta 401), reused 264 (delta 213)
remote: Resolving deltas: 100% (401/401)
remote: Processing changes: refs: 1, done
remote: (W) d40d4c1: commit subject >50 characters; use shorter first 
paragraph
remote: (W) d40d4c1: too many commit message lines longer than 72 
characters; manually wrap lines
remote: ERROR: [72fe4c9] 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 
yyyyyy@gerrit.xyz.se:hooks/commit-msg ${gitdir}/hooks/
remote: And then amend the commit:
remote:   git commit --amend
remote:
To ssh://gerrit.zyz.se:29418/xyz/com.xyz.cifwk.diagmon/ddp
! [remote rejected]     HEAD -> refs/for/master ([72fe4c9] missing Change-Id 
in commit message footer)
error: failed to push some refs to 
'ssh://gerrit.xyz.se:29418/xyz/com.xyz.cifwk.diagmon/ddp'

3 个答案:

答案 0 :(得分:0)

如错误消息中所述,您尝试在其提交消息中推送不具有所需更改ID的其他提交72fe4c9

您可以使用git log -p查看提交,并使用git rebase -i解决问题。

答案 1 :(得分:0)

我猜你在创建git pull之前没有-r--rebase就运行bb4bfe6f068b4f21414610e28f9216ada2810310并创建了合并提交。这很可能是72fe4c9。合并提交不会调用commit-msg来生成Change-Id。因此,您需要为该合并提交72fe4c9生成Change-Id,或者只需将本地新的非合并提交重新绑定到目标分支的最新HEAD上:

git fetch origin master
git rebase FETCH_HEAD
git push origin HEAD:refs/for/master

答案 2 :(得分:0)

希望它会对你有所帮助,先拉:

git pull --rebase origin master

然后,尝试推动:

git push origin master