Search code examples
gitgerrit

Add Change-Id to all commits


I just installed Gerrit and I wanted to do a push to it, but I'm getting an error regarding Change-Id, but it appears to be in the commit it's complaining about.

$ git push gerrit HEAD:refs/publish/my-branch
Counting objects: 28, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (15/15), 4.46 KiB, done.
Total 15 (delta 12), reused 0 (delta 0)
remote: Resolving deltas: 100% (12/12)
remote: Processing changes: refs: 1, done    
remote: ERROR: missing Change-Id in commit message footer
remote: Suggestion for commit message:
remote: Revert "Refactoring controllers"
remote: 
remote: This reverts commit dd1c5c86b12461f61326fd102a11d9e3cb51142e.
remote: 
remote: Change-Id: Iaacf80a9e4f56b58d0b648112c3eb2413988f00e
remote: 
remote: Hint: To automatically insert Change-Id, install the hook:
remote:   gitdir=$(git rev-parse --git-dir); scp -p -P 29418 user@ci:hooks/commit-msg ${gitdir}/hooks/
remote: 
remote: 
To ssh://user@ci:29418/Project
! [remote rejected] HEAD -> refs/publish/my-branch (missing Change-Id in commit message footer)
error: failed to push some refs to 'ssh://user@ci:29418/Project'

I assume that this is because of previous commits that are without Change-Id because they were made prior to having the hook. How can I update all previous commits to add the Change-Id?


Solution

  • In Gerrit - at the project settings page disable the option which requiring change-Id in commits temporarily. Then push the existing commits to Gerrit.