Gerrit recreating change-ids
If git commit --amend
or git commit --amend -m "...."
doesn't help and gerrit still complains about the missing change-Id. (This happens due to network issues mostly)
This is how I got it resolved (Made sure I had the commit-msg hook applied, on parent directory of the checked-out directory reference):
- Stash the Changes using
git stash
. - Used
gitk &
to hard rebase the change to just previous commit. - Then pull and rebase from Repo
git pull --rebase
. - Then apply the stashed changes using
git stash apply
, reference. Resolve Merger Conflicts if any usinggit mergetool
. - Recommitted in the change again using
git commit
orgit commit --amend
, this generated a new change-Id - Push the changes to branch on repository using
git push ...
command.
There is similar question around as well for reference
git commit --amend
- Manually delete the Change-Id line, save and close
git commit --amend --no-edit
And the hook will create a new Change-Id hash, in the absence of one.
commit-msg hook work that way:
- Check if you have change-id in your commit message.
- If not, generates one.
If you type git commit --amend
and edit commit message, you still have old change-id (it is good).
But if you type git commit --amend -m "...."
you have removed change-id, so gerrit generates new one.
Rule of a thumb:
Don't use --amend -m
with gerrit.