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
?
When you have hook, you can do rebase branch into itself in interactive mode
git checkout branchName
git rebase -i branchName
When you see interactive menu change keyword pick
to edit
near every commit that you have no change id. Then git will stop before "rebasing" every commit that marked as edit
. On every stop you do git commit --amend
,save changes(change id will be added automatically, if you have commit hook hrom gerrit, othrwise you need to add it manually), and then git rebase --continue
. After that every commit in your branch will have change-id.
Rince and repeat for every branch you need.
In Gerrit - at the project settings page disable the option which requiring change-Id in commits temporarily. Then push the existing commits to Gerrit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With