Reputation: 41
I have git, version 1.9.5.msysgit and am using Gerrit 2.10 as code-review tool. I would like to know where Change-ID gets stored in a locally cloned repository.
After successfully pushing a few changes to a remote branch from my local branch, git push surprisingly gives me an error for the current commit saying:
remote: ERROR: missing Change-Id in commit message footer
remote: Change-Id: I197b74458ae304ad512d96c4ac905c6d3afc4da4
remote: Hint: To automatically insert Change-Id, install the hook:
remote: gitdir=$(git rev-parse --git-dir); scp -p -P 29418 abc.xyz@serverip:hooks/commit-msg ${gitdir}/hooks/
Before, I got this error I could push a few changes to a remote without any issues being in the same cloned branch. However, all of a sudden, I am getting this error.
When I checked my local log, I could see that the current commit already has a Change-Id, but git push says the Change-Id is missing.
There are no changes in the commit-msg file which is actually used to generate Change-Ids.
If I could see where this Change-Id is getting stored, maybe I could see the difference between already existing Change-Id and the one producing the Error message.
I read about this https://groups.google.com/forum/#!topic/repo-discuss/aq98R4-4TqI
I am scratching my head like crazy. How do I fix this?
Upvotes: 1
Views: 2482
Reputation: 25373
The change-id from Git's point of view is just stored in the commit message of commits.
Gerrit uses these change id's to associate commits together (as patch-set's) that make up a change.
Make sure that there is an empty line in-between your commit message and the change-id and that the change-id is the very last line.
For example:
>>git show
commit eafbc99b9343a5e060ece5c95b050c3fc541f292
Author: John Doe <[email protected]>
Date: Tue Sep 1 16:12:17 2015 -0400
My commit message header
This commit is...
Change-Id: I511a54c1ec18e59615d76f89d57c0a7cc03b6f5c
You may want to re-run this command (from Git's output), and the amend your commit:
gitdir=$(git rev-parse --git-dir); scp -p -P 29418 abc.xyz@serverip:hooks/commit-msg ${gitdir}/hooks/
git commit --amend
Upvotes: 1
Reputation: 387527
The Gerrit change id is simply part of the commit message. So here, Gerrit asks you to add the change id to the commit message so it can link the commit the change and vice-versa.
To do that, simply amend your commit using git commit --amend
. This will bring up your editor, and then just add the following line to the end:
Change-Id: I197b74458ae304ad512d96c4ac905c6d3afc4da4
E.g.
This is the commit summary
There can also be some extra text in the commit message.
Change-Id: I197b74458ae304ad512d96c4ac905c6d3afc4da4
Usually, you would install the commit hook as suggested by the hint in the error message. That way, whenever you commit, a new change ID is appended to the commit message. So you don’t need to do that manually.
Upvotes: 0