Gerrit recreating change-ids

Related searches

I am using gerrit. I used the following command

$ cd .git/hooks
$ scp -P 29418 demo@localhost:hooks/commit-msg .
$ cd ../..

This adds the change-id to my commit message, however if I amend to a commit it creates a NEW change-id. So when I push back to gerrit it's not adding the patch set, it's creating a whole new review entry.

Any suggests please?

Found the answer, but stackoverflow won't let me answer my own question.

So this was a complete error on my part. When I was trying to commit git commit --amend -m "Initial Commit"

I was inlining the commit message and that was wiping away the change-Id, thus giving me a new one.

commit-msg hook work that way:

  1. Check if you have change-id in your commit message.
  2. 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.

Gerrit recreating change-ids, 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� Change-Ids are created at commit time on the client side. A standard 'commit-msg' hook is provided by Gerrit, and can be installed in the local Git repository to automatically generate and insert a Change-Id line during git commit , when none is defined yet.

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):

  1. Stash the Changes using git stash.
  2. Used gitk & to hard rebase the change to just previous commit.
  3. Then pull and rebase from Repo git pull --rebase.
  4. Then apply the stashed changes using git stash apply, reference. Resolve Merger Conflicts if any using git mergetool.
  5. Recommitted in the change again using git commit or git commit --amend, this generated a new change-Id
  6. Push the changes to branch on repository using git push ... command.

There is similar question around as well for reference

Gerrit Code Review - Change-Ids, Gerrit supports two protocols for uploading changes; SSH and HTTP/HTTPS. If Change-Id lines are not present in the commit messages, consider amending the message and copying the line from Creating Changes for Merged Commits. Gerrit Code Review sometimes relies upon a Change-Id line at the bottom of a commit message to uniquely identify a change across all drafts of it. By including a unique Change-Id in the commit message, Gerrit can automatically associate a new version of a change back to its original review, even across cherry-picks and rebases.

  1. git commit --amend
  2. Manually delete the Change-Id line, save and close
  3. git commit --amend --no-edit

And the hook will create a new Change-Id hash, in the absence of one.

Uploading Changes, With this error message Gerrit rejects to push a commit if it contains the same Change-Id as a predecessor commit. The reason for rejecting such a commit is that� Note that removing the Change-Id (without letting the commit-msg hook add a new one) generally is a bad idea as it breaks Patch-Set tracking in Gerrit, meaning a new iteration of the commit would not be associated to the previous iteration.

same Change-Id in multiple changes, This is a tutorial which explains how to use Git and Gerrit for Wikimedia If a command also include a variable which you must to change yourself, then the� Gerrit recreating change-ids. 0. Pushing long commit message gerrit. 36. Git / gerrit, push remote rejected no changes made. 14. Searching Gerrit by Commit Message. 5.

Gerrit/Tutorial - MediaWiki, Gerrit provides a commit-msg hook script that will automatically add change-ids to your commits. The documentation to which I linked provides instructions for installing it: To obtain the commit-msg script use scp, wget or curl to download it to your local system from your Gerrit server.

Gerrit recreating change-ids. Related. Hot Network Questions Plot involving an implicit function Find the values of α and β for which this series converges.

Comments
  • Are you sure that the ChangeId is in the last paragraph of the commit message? Have a look at: ChangeId
  • Mmmm, I have just finished reading your question :-) and yes, the -m is a typical error.
  • If you really wanted to, one could write a prepare-commit-msg hook that would squirrel away the changeid and then put it back on.
  • Yikes! found this too late :)
  • --ammend and -m do work ... you just have to remember to to a git rebase --interactive before pushing - to cleanup things. And of course, you have to make sure to not change the change id when doing so ;-)
  • That is in fact the easiest way to re-generate change-id, and shall be accepted as a correct way