Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

merge commit does not have change id?

Tags:

git

merge

gerrit

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?

like image 380
Obuli Sundar Avatar asked Feb 14 '26 01:02

Obuli Sundar


1 Answers

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:

  1. 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/.

  2. 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.

  3. push to gerrit

    $ git push origin HEAD:refs/for/master
    

    Replace branch and remote with your own if needed.

like image 106
Tim Avatar answered Feb 16 '26 17:02

Tim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!