Obuli Sundar Obuli Sundar - 7 months ago 45
Git Question

merge commit does not have change id?

I am hard resetting one branch to another. After merging it with the

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.


  1. Download the commit-msg hook from gerrit

    $ scp -p -P 29418 TimCastelijns@server.timcastelijns.nl: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.