Why does TortoiseGit run prepare-commit-msg after commit message edit?

1.3k views Asked by At

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:

Commit using Git Bash

But if I commit using TortoiseGit both hooks run after message edit:

Commit using TortoiseGit

I know that TortoiseGit has settings for hooks scripts (Start Commit, Pre-Commit,...), but I have none of those set to any value.

1

There are 1 answers

0
MrTux On

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).