Gerrit error when Change-Id in commit messages are missing

前端 未结 12 1145
北荒
北荒 2020-11-28 03:58

I set up a branch in the remote repository and made some commits on that branch. Now I want to merge the remote branch to the remote master.

Basically follows are my

相关标签:
12条回答
  • 2020-11-28 04:32

    under my .git/hooks folder, some sample files were missing. like commit-msg,post-commit.sample,post-update.sample...adding these files resolved my change id missing issue.

    0 讨论(0)
  • 2020-11-28 04:34

    Check if your commits have Change-Id: ... in their descriptions. Every commit should have them.

    If no, use git rebase -i to reword the commit messages and add proper Change-Ids (usually this is a SHA1 of the first version of the reviewed commit).

    For the future, you should install commit hook, which automatically adds the required Change-Id.

    Execute scp -p -P 29418 username@your_gerrit_address:hooks/commit-msg .git/hooks/ in the repository directory or download them from http://your_gerrit_address/tools/hooks/commit-msg and copy to .git/hooks

    0 讨论(0)
  • 2020-11-28 04:34

    Try this:

    git commit --amend
    

    Then copy and paste the Change-Id: I55862204ef71f69bc88c79fe2259f7cb8365699a at the end of the file.

    Save it and push it again!

    0 讨论(0)
  • 2020-11-28 04:34

    You need to follow below 2 steps instructions:

    [Issue] remote: Hint: To automatically insert Change-Id, install the hook:

    1) gitdir=$(git rev-parse --git-dir);

    2) scp -p -P 29418 <username>@gerrit.xyz.se:hooks/commit-msg ${gitdir}/hooks/

    normally $gitdir = ".git". You need to update the username and the Gerrit link.

    0 讨论(0)
  • 2020-11-28 04:35

    1) gitdir=$(git rev-parse --git-dir);

    2) scp -p -P 29418 <username>@gerrit.xyz.se:hooks/commit-msg ${gitdir}/hooks/
    

    a) I don't know how to execute step 1 in windows so skipped it and used hardcoded path in step 2 scp -p -P 29418 <username>@gerrit.xyz.se:hooks/commit-msg .git/hooks/

    b) In case you get below error, manually create "hooks" directory in .git folder

    protocol error: expected control record
    

    c) if you have submodule let's say "XX" then you need to repeat step 2 there as well and this time replace ${gitdir} with that submodules path

    d) In case scp is not recognized by windows give full path of scp

    "C:\Program Files\Git\usr\bin\scp.exe"
    

    e) .git folder is present in your project repo and it's hidden folder

    0 讨论(0)
  • 2020-11-28 04:41

    I got this error message too.

    and what makes me think it is useful to give an answer here is that the answer from @Rafał Rawicki is a good solution in some cases but not for all circumstances. example that i met:

    1.run "git log" we can get the HEAD commit change-id
    
    2.we also can get a 'HEAD' commit change-id on Gerrit website.
    
    3.they are different ,which makes us can not push successfully and get the "missing change-id error"
    

    solution:

    0.'git add .'
    
    1.save your HEAD commit change-id got from 'git log',it will be used later.
    
    2.copy the HEAD commit change-id from Gerrit website.
    
    3.'git reset HEAD'
    
    4.'git commit --amend' and copy the change-id from **Gerrit website** to the commit message in the last paragraph(replace previous change-id)
    
    5.'git push *' you can push successfully now but can not find the HEAD commit from **git log** on Gerrit website too
    
    6.'git reset HEAD'
    
    7.'git commit --amend' and copy the change-id from **git log**(we saved in step 1) to the commit message in the last paragraph(replace previous change-id)
    
    8.'git push *' you can find the HEAD commit from **git log** on Gerrit website,they have the same change-id
    
    9.done
    
    0 讨论(0)
提交回复
热议问题