gitgithooksgit-cherry-pickpost-commit-hook

Why doesn't `git cherry-pick` (without `--no-commit`) run my post-commit hook?


How can I trigger a post-commit hook with the command git cherry-pick <commit>?

What I've tried:

My questions are:

  1. Why don't post-commit hooks work when I use git cherry-pick?
  2. Is there a hook that cherry-pick will run?

Solution

  • Why don't post-commit hooks work when I use git cherry-pick?

    The post-commit hook is run after creating a commit.

    However, cherry-pick does not really create a new commit with new information (from the user perspective) but copies another commit.

    Is there a hook that cherry-pick will run?

    Yes, the prepare-commit-msg should be run before commit is cherry-picked, even though the commit-msg hook is not executed.