System description:
- Windows 7
- git version 2.10.1.windows.1
- TortoiseGit 2.3.0.0
I want:
The merge commit message to be different in a fully automated manner (no manual amend
)
Summary:
On windows, using tortoiseGit, there is no prepare-commit-msg
hook, only start-commit-hook
and no matter what the hook script is, I get a windows popup error:
%1 is not a valid Win32 application
Also, I would prefer to only change the commit messages which are "merges".
Steps:
setup the hook:Set the working tree path to be same as my project's path,
and in "Command Line To Execute" I select the file I prepared:
.git\hooks\prepare-commit-msg
which its content is echo "test"
.
Then I try to do a commit and get this error:
I've made sure that this script file is indeed the file which is used,
because if I delete it, I get this message:
TortoiseGit hooks are fully independent of vanilla Git hooks.
You can use any script language or executable as TortoiseGit hook script. However, in the configuration you have to enter a a valid Windows executable as command, e.g. an .exe
file, for .js
or .vbs
scripts you need to specify the interpreter (wscript
or cscript
) and the path to the script as the interpreter parameter (cf. here). For executing a bash script I think you need to execute bash.exe with the appropriate parameters to a script - I haven't tested this before.
The executed hook gets some parameters from TortoiseGit, those are documented here, e.g. the Start-commit
is called when the commit dialog is opened and gets three cli parameters: PATH MESSAGEFILE CWD, whereas PATH is a path to a file containing all entries of the commit dialog, MESSAGEFILE is the path to a file where you can put the contents to which should be used as commit message and CWD is the working tree path.
Examples can be found on https://github.com/TortoiseGit/TortoiseGit/tree/master/contrib/hook-scripts/client-side
PS: In order to check whether this is a merge commit you can check for the existance of .git/MERGE_HEAD
.
来源:https://stackoverflow.com/questions/39959434/tortoisegit-change-default-merge-message