Search code examples
gitintellij-ideapre-commit-hook

How to make IntelliJ IDEA respect pre-commit-msg hook


I would like to prefill the commit message depending on the branch name I am currently on. I have this working with a pre-commit-msg hook from the command line but when commiting from IDEA there is no effect. The commit msg is prepopulated by the last commit msg (I think?). Is there a way to get this working?

Edit: I just found out that the hook is working when I reword a commit message in IDEA. But that's not what I want.


Solution

  • This is not possible, unfortunately. Commit dialog is shown before any git commit operations are called, that is why the hook is never executed.

    Please follow https://youtrack.jetbrains.com/issue/IDEA-114680

    Maybe a plugin like this may help you to achieve your goal: https://plugins.jetbrains.com/plugin/9278-pre-commit-hook-plugin