0

I am using Git with Gerrit and trying to push the changes with the following command

 git push origin HEAD:refs/for/master

which is failing with following error message

Counting objects: 54, done. Delta compression using up to 4 threads. Compressing objects: 100% (23/23), done. Writing objects: 100% (54/54), 4.56 KiB | 0 bytes/s, done. Total 54 (delta 20), reused 0 (delta 0) remote: Resolving deltas: 100% (20/20) remote: Processing changes: refs: 1, done remote: ERROR: [041a9f9] 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 urid@gerrit.ext.net.something.com:hooks/commit-msg ${gitdir}/hooks/ remote: And then amend the commit: remote: git commit --amend remote: To ssh://gerrit.ext.net.something.com:29418/Project/FolderName ! [remote rejected] HEAD -> refs/for/master ([041a9f9] missing Change-Id in commit message footer) error: failed to push some refs to 'ssh://username@gerrit.ext.net.something.com:29418/Project/FolderName'

So as mentioned in above error message i run below command

--git-dir); scp -p -P 29418 urid@gerrit.ext.net.something.com:hooks/commit-msg ${gitdir}/hooks/

and output was

commit-msg
100% 4682 23.0KB/s 00:00

So it mean hook downloaded properly in my project working directory after that i run the command

git commit --amend

and it is showing proper Change-Id: I55862204ef71f69bc88c79fe2259f7cb8365699a and as mentioned in this documents its in the last line only.

But still i am not able to push the changes i tried to get help from this question but still its failing with same message.

Update 1 Here is the output of

$ git log

commit 10690fb1b829981852855aecaab0dfd7aaf9997f (HEAD -> master) Author: Author Name

Date: Wed Jun 6 18:42:25 2018 +0530

SUREREQ-6877:Support of PATCH and OPTIONS

Change-Id: Ic7f36b90832078afa740b1138cb35829456f389d

commit 041a9f9deeae886c9771995a1463d40ca2d3fa3c Merge: e265b88b 7f2ec936 Author: Author Name Date: Wed Jun 6 17:33:48 2018 +0530

Merge branch 'master' of ssh://gerrit.ext.net.nokia.com:29418/SURE/sure-sw

commit e265b88b6194f65dedbf070b2be7f6c7018f6dec Author: Author Name
Date: Wed Jun 6 16:59:58 2018 +0530

SUREREQ-6877:Support of PATCH and OPTIONS

Change-Id: I82382926d5acd8f9101bd3fc7bbb33bae85672da

commit 7603b20691b59de2f086ca5633314f89bcc963ab Author: Author Name
Date: Wed Jun 6 16:53:04 2018 +0530

SUREREQ-6877:Support of PATCH and OPTIONS

Change-Id: I9312ebbe3d346ff97ca996c2219f204a55d1b9ac

commit 305fd46084f2a230f96b316f814ebf0eabd849c2 Author: Author Name
Date: Wed Jun 6 16:52:24 2018 +0530

SUREREQ-6877:Support of PATCH and OPTIONS

Change-Id: I011e3e3c22954774e99462c585a54cf9a0aad428

commit 8b1059922745a605851f4a9bd6cae3193a85c62c Author: Author Name
Date: Wed Jun 6 16:49:15 2018 +0530

SUREREQ-6877:Support of PATCH and OPTIONS

Change-Id: Ic9d9e7e787f8a826f18f361cf0c20930c42bf04b

commit 7f2ec936f4133988194b14dca910fb921a6946be (origin/master, origin/HEAD)

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202

3 Answers3

1

It seems that the issue is not in the last commit. Probably the issue (the missing Change-Id) is on a parent commit. Execute the git log command and inspect your commit history looking for any new commit without the Change-Id. Remember: all new commits must have a unique Change-Id. If this is the case, you need to use the git rebase -i command to add the Change-Id to the commits.

Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202
0

You commit 041a9f9deeae886c9771995a1463d40ca2d3fa3c is a merge commit and it does not have a Change-ID. This was probably created locally and Git does not run the commit-msg hook on merge commits. You need to make sure that you fix this before you can submit your change.

uncletall
  • 6,609
  • 1
  • 27
  • 52
0

Try git pull origin -r master to flatten the merge commit in which Change-Id is missing. The merge commit is redundant.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53