Realistically there's nothing the tools can do. The cherry-pick
command just automates the creation of a commit whose patch happens to match that of another existing commit; there is nothing special about the resulting commit, so even a hook wouldn't really have a way to pick out the fact that a commit was cherry-picked.
I say this as someone who doesn't really like cherry-pick
- or, at least, thinks it's over-used and over-recommended. But even if you found a way to prevent cherry-pick
, a dev wanting to do it could just work out the simple rebase
approach to do the same thing. Or they could manually generate the patch for the source commit and manually apply it to the target branch, making it indistinguishable from a hand-coded commit in terms of the git commands issued.
And that last sentence should make clear, even if you change source control tools to one that doesn't have a concept of cherry-pick
, the devs can still do the same thing by hand, if it's what they feel motivated to do.
Sometimes the problem isn't a technical problem.