如何在 Windows 上运行 git hook 脚本,通过文件系统使用存储库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23384196/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 11:32:48  来源:igfitidea点击:

How to run git hook script on windows, using repository through filesystem?

windowsgitgithooks

提问by Fanda

Because of its simplicity, we use remote repository placed on shared disk, accessing it using file system path (\server\share). Is is possible, in such case, to run hook scripts defined in remote repository? I have defined one but it seems like it is not launched (tested using non valid edit in hook script, witch should cause an error).

由于它的简单性,我们使用放置在共享磁盘上的远程存储库,使用文件系统路径(\server\share)访问它。在这种情况下,是否可以运行远程存储库中定义的钩子脚本?我已经定义了一个,但它似乎没有启动(使用钩子脚本中的无效编辑进行测试,女巫应该会导致错误)。

回答by Blaise

Git hook is a script you can run before (pre-commit) or after (post-commit) a commit is made. There can be more than one of such a script.

Git hook 是一个脚本,您可以在提交之前(预提交)或之后(提交后)运行。可以有多个这样的脚本。

They are placed in a specified folder. Any git repository has a .git/hooksfolder with file(s) containing hook scripts.

它们被放置在指定的文件夹中。任何 git 存储库都有一个.git/hooks文件夹,其中包含包含钩子脚本的文件。

You need to answer Do you have the event you are testing bind to a hook present in your's git repository?

你需要回答你是否有你正在测试的事件绑定到你的 git 存储库中的一个钩子?

Check also this on how git executes hooks in Windows:

也检查一下 git 如何在 Windows 中执行钩子:

Tips for using hooks:

使用钩子的技巧:

Some more git hooks reading:

更多的 git 钩子阅读:

回答by GetoX

My advice after few hours of fight, double check value:

经过几个小时的战斗,我的建议是,仔细检查价值:

git config core.hookspath

It should be empty or point your hooks folder (.git\hooks)

它应该为空或指向您的 hooks 文件夹 ( .git\hooks)