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

一世执手 提交于 2021-02-19 06:37:06

问题


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:


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



来源:https://stackoverflow.com/questions/41286739/why-does-tortoisegit-run-prepare-commit-msg-after-commit-message-edit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!