git - 如何从 pre-push git hook 运行 .exe?
问题描述
所以这是我在谷歌搜索超过 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"
推荐阅读
- sql - 如何修复此列在 SQL 中不存在错误?
- android - 在静态方法中使用静态 android 上下文
- react-native - 如何在 React Native 测试库中获取 React 测试渲染器实例
- ionic-framework - 如何在离子网络应用程序中通过命令清除缓存?
- jsf - 如何在 JSF 中为不同的 PROJECT_STAGE 获取不同的错误页面
- json - REST:请求作为响应的子集
- python - PySpark S3 Internal S3 (jupyter notebook) - 错误 - 名称或服务未知
- python - 在小时间范围内对序列数据训练 RNN 模型是否可行?
- python - 如何打印格式指数
- python - TypeError: If class_mode="categorical", y_col 列值必须是字符串、列表或元组类型