I am trying to find a way to check commits when cherry-picking them. Unfortunately, I cannot find a git hook that works with cherry-pick
operation. What would be a possible solution to execute a script on cherry-picked commit?
As the other told in the comments above, there is no direct cherry-pick hook.
But I can propose you a workaround , that could work under certain conditions:
Some git front-ends add a default commit message to every cherry-pick commit.
Here just as an example GitExtension where a cherry pick command shows you a dialogue called "Cherry pick commit" with a tickable option "Add commit reference to commit message". With this option the commit message will look like eg:
Fix of security problem sp345
(cherry picked from commit c157f17740bad0c8c59ff3f693a747552008371d)
# Conflicts:
# authorization/secure/check.py
A commit-msg hook could be written doing this:
cherry picked from commit
There is only one condition required: That every committer follows the rule to add (via tool or manually) the text to the commit message that is needed to detect it properly as a cherry-picked commit.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.