如何从预推 git 挂钩中 运行 .exe?

How to run .exe from pre-push git hook?

这是我在 google 上搜索了 4 个多小时后得到的结果:

#!C:/Program\ Files/Git/bin/sh.exe echo $SHELL echo "here we go" ./PrePush/GitHook.exe

控制台告诉我:

/usr/bin/bash here we go .git/hooks/pre-push: line 4: ./PrePush/GitHook.exe: No such file or directory

我的 .exe 位于:C:\Users\myUsername\Documents\MyRepos\ProjectName\.git\hooks\PrePush\GitHook.exe 但它可以是我同事驱动器上的任何路径,所以我必须使用本地路径。

我已经尝试过 bin/bash.exe,使用完整路径,使用 system(./PrePush/GitHook.exe)(因为我认为它是一个 perl 脚本) 但他们都提出了错误。

并且似乎没有从 git 挂钩“只是”调用本地 .exe 的示例。

Git 挂钩不会从 .git/hooks 文件夹中执行。您必须指定可执行文件的正确路径。

"$(git rev-parse --git-dir)/hooks/PrePush/GitHook.exe"