I am hard resetting one branch to another. After merging it with the ours strategy, I try to push through gerrit. I am getting an error like "missing change id". By default, the merge commit does not have a change id. I have tried to download the commit-msg hook for automatic change id. But it does not help in Windows. Any idea how to add change the id in a merge commit?
Situation: you have a commit that needs to be pushed to gerrit, but the commit has no change-id and gerrit won't accept it.
Solution:
Download the commit-msg hook from gerrit
$ scp -p -P 29418 [email protected]:hooks/commit-msg tims-project/.git/hooks/
Do replace the port number, server address and project name with your own. Also, change the path of tims-project/.git/hooks/ depending on your current location in the terminal. The hook has to go into <project_dir>/.git/hooks/.
Go to your repo folder and amend the merge commit
$ cd tims-project/
$ git commit --amend
In the editor that pops up when you amend, the current commit and it's commit message are shown. Do nothing here. Simply exit & save the editor. Because of the commit-msg hook which is a post-commit hook, any commit that is made (created or amended) automatically gets assigned a change-id.
push to gerrit
$ git push origin HEAD:refs/for/master
Replace branch and remote with your own if needed.
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