Ped*_*der 2 git tortoisegit git-bash
我的 .git/hooks 目录中有两个挂钩文件“prepare-commit-msg”和“commit-msg”:
准备-提交-消息
#!/bin/bash
echo "prepare-commit-msg"
exit 0
Run Code Online (Sandbox Code Playgroud)
提交消息
#!/bin/bash
echo "commit-msg"
exit 0
Run Code Online (Sandbox Code Playgroud)
如果我使用 Git Bash 提交,则按预期在消息编辑之前运行“prepare-commit-msg”,并在消息编辑之后运行“commit-msg”:

但是如果我使用 TortoiseGit 提交,两个钩子都会在消息编辑后运行:

我知道 TortoiseGit 有钩子脚本的设置(开始提交、预提交……),但我没有将这些设置为任何值。
TortoiseGit 执行git.exe commit -m mesagefile.txt提交。因此 git commit 命令会执行所有 git hook,因为无法使用命令行参数禁用这些 hook。
请参阅https://tortoisegit.org/issue/1091
如果您需要可以更改提交消息的钩子,请使用 TortoiseGit 自己的钩子(参见https://tortoisegit.org/docs/tortoisegit/tgit-dug-settings.html#tgit-dug-settings-hooks)。