fish potato fish potato - 1 year ago 155
Git Question

get commit message in git hook

I would like to check commit message before git commit.
I use pre-commit hook to do that, but couldn't find the way to get commit message in .git/pre-commit script.
How could I get it?

Answer Source

In the pre-commit hook, the commit message hasn't been created yet. You probably want to use one of the prepare-commit-msg or commit-msg hooks instead. There's a nice section in Pro Git on the order in which these hooks are run, and what you typically might do with them.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download