Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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).

like image 572
Fanda Avatar asked Apr 30 '14 09:04

Fanda


People also ask

Are Git hooks stored in repo?

By default hooks are stored in . git/hooks outside of the working tree and are thus not shared between users of the repository. The hooks can be included in a directory within the repository and then each developer can set Git up to use them.

What directory do Git hooks run in?

By default the hooks directory is $GIT_DIR/hooks , but that can be changed via the core. hooksPath configuration variable (see git-config[1]). Before Git invokes a hook, it changes its working directory to either $GIT_DIR in a bare repository or the root of the working tree in a non-bare repository.


2 Answers

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/
like image 140
Blaise Avatar answered Oct 02 '22 09:10

Blaise


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)

like image 37
GetoX Avatar answered Oct 02 '22 10:10

GetoX