Question

We use Git together with Gerrit, and commit hook is used to generate change id for Gerrit. Now question is when cherry-picking commits, the commit hook is not triggered, hence same change id may exist for different commits in different branch. Any quick win to make change id being regenerated during cherry-picking?

Thanks.

Was it helpful?

Solution

If you are using a recent enough version of Gerrit, it is actually desired to reuse the same Change-Id when cherry picking a commit to a different branch. This is an effective method to track which branches contain a bug fix, and it works well for us at $DAYJOB.

Earlier versions of Gerrit had issues with duplicate change-ids, but this concept of duplicate change-ids on different branches has been supported for quite some time now.

OTHER TIPS

Just use git commit --amend on cherry-picked commit and remove 'Change-Id:' line from commit message. If a proper hook is installed (likely it is) then a new Change-Id will be generated.

They don't need to be different, gerrit allows each change-id to exist once on each branch so it's fine to have the same on each branch.

if you want to cherry-pick a closed review, then need generate a new change id, pls: git cherry-pick --> git commit --amend,remove the change-id line --->git push, it will create new change id.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top