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

前端 未结 3 1885
暖寄归人
暖寄归人 2020-12-24 08:01

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 s

相关标签:
3条回答
  • 2020-12-24 08:11

    If you run the command:

    git config core.hooksPath .git-hooks
    

    This will look for the hooks in the folder .git-hooks from your project root, same as where you find .git folder. When the commands are run in this folder, take note that the directory being executed from then is the project root - and not in the .git-hooks folder having the actual hooks. This is why you get the "command not found".

    Example contents of .git-hooks/post-merge file

    !#!/bin/bash
    bower install
    

    The "bower install" command is run from the parent directory.

    0 讨论(0)
  • 2020-12-24 08:14

    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)

    0 讨论(0)
  • 2020-12-24 08:17

    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.

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

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

    Check also this on how git executes hooks in Windows:

    • Executing Git hooks on Windows
    • Git Hook under Windows

    Tips for using hooks:

    • https://codeinthehole.com/tips/tips-for-using-a-git-pre-commit-hook/
    • https://omerkatz.com/blog/2013/2/15/git-hooks-part-1-the-basics
    • http://longair.net/blog/2011/04/09/missing-git-hooks-documentation/

    Some more git hooks reading:

    • http://git-scm.com/book/en/Customizing-Git-Git-Hooks
    • http://githooks.com/
    0 讨论(0)
提交回复
热议问题