I have two hook files, "prepare-commit-msg" and "commit-msg" in my .git/hooks directory:
prepare-commit-msg
#!/bin/bash
echo "prepare-commit-msg"
exit 0
commit-msg
#!/bin/bash
echo "commit-msg"
exit 0
If I commit using Git Bash "prepare-commit-msg" is run before message edit and "commit-msg" after message edit, as expected:
But if I commit using TortoiseGit both hooks run after message edit:
I know that TortoiseGit has settings for hooks scripts (Start Commit, Pre-Commit,...), but I have none of those set to any value.
TortoiseGit executes
git.exe commit -m mesagefile.txt
for commit. Therefore the git commit command executes all git hooks as there is no way to disable those using command line parameters.Please see https://tortoisegit.org/issue/1091
If you need hooks which should alter the commit message please use TortoiseGit's own hooks (cf https://tortoisegit.org/docs/tortoisegit/tgit-dug-settings.html#tgit-dug-settings-hooks).