为什么在提交消息编辑后TortoiseGit会运行prepare-commit-msg? [英] Why does TortoiseGit run prepare-commit-msg after commit message edit?
问题描述
我的.git/hooks目录中有两个钩子文件,"prepare-commit-msg"和"commit-msg":
I have two hook files, "prepare-commit-msg" and "commit-msg" in my .git/hooks directory:
准备提交消息
#!/bin/bash
echo "prepare-commit-msg"
exit 0
commit-msg
#!/bin/bash
echo "commit-msg"
exit 0
如果我使用Git Bash提交,则按预期方式在消息编辑之前运行"prepare-commit-msg",在消息编辑之后运行"commit-msg":
If I commit using Git Bash "prepare-commit-msg" is run before message edit and "commit-msg" after message edit, as expected:
但是,如果我使用TortoiseGit提交,则在消息编辑后两个钩子都将运行:
But if I commit using TortoiseGit both hooks run after message edit:
我知道TortoiseGit具有用于钩子脚本的设置(启动提交,预提交等),但是我没有将这些设置为任何值.
I know that TortoiseGit has settings for hooks scripts (Start Commit, Pre-Commit,...), but I have none of those set to any value.
推荐答案
TortoiseGit执行 git.exe commit -m mesagefile.txt
进行提交.因此git commit命令会执行所有git钩子,因为无法使用命令行参数禁用那些钩子.
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.
请参阅 https://tortoisegit.org/issue/1091
如果您需要可以改变提交消息的钩子,请使用TortoiseGit自己的钩子(参见
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).
这篇关于为什么在提交消息编辑后TortoiseGit会运行prepare-commit-msg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!