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.
A cherry-pick is basically a commit, so if you want to undo it, you just undo the commit. Stash your current changes so you can reapply them after resetting the commit.
It takes changes from a specific commit and applies them to your current branch in a new commit. As a consequence, git cherry pick does not alter your current Git history : instead it adds commits to it.
Updating an old commit If a commit was created before the availability of Change-Id support, or was created in a Git repository that was missing the 'commit-msg' hook, simply copy the “Change-Id: I… ” line from the first line of the Description section of the change and amend it to the bottom of the commit message.
To squash the commits, use git rebase -i to do an interactive rebase. For the example above where the last two commits have the same Change-Id, this means an interactive rebase for the last two commits should be done. For further details about the git rebase command please check the Git documentation for rebase.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With