[ACCEPTED]-git cannot execute python-script as hook-githooks

Accepted answer
Score: 19

I used the proxy-approach to make the python 34 script work under windows (with msysgit). The 33 complete script (with description on how 32 I did it) might be found here: https://gist.github.com/1839424

Here is the 31 important part about making it work under 30 Windows

If you're working with Windows (and 29 "msysgit"), it's a little more 28 complicated. Since "msysgit" seems 27 to have a problem handling the SHEBANG, you'll 26 have to use a little trick to make the script 25 executable (further information on this 24 problem can be found here).

In order to make 23 the script work, you'll want to remove the 22 SHEBANG from the Python script ("pre-commit.py") and 21 use a wrapper bash-script to call the interpreter. This 20 script should look something like this:

python .git/hooks/pre-commit.py

Store 19 this script as a file called "pre-commit" (no 18 file-ending). This assumes that you have 17 Python in your PATH. If you don't, you can also 16 specify the full path to your interpreter-executable.

This 15 script will be called by "git commit" and 14 call the python-script to check for the 13 huge files. The path after the SHEBANG should 12 not be changed, as "msysgit" will 11 remap it automatically. You must specify 10 a path relative to the repo-root for the 9 Python script to be executed (because thats 8 from where the script is called).

Afterwards 7 you'll want to copy both the wrapper-file 6 ("pre-commit") and the Python-script 5 ("pre-commit.py") to your repos 4 ".git/hooks"-directory, personalize 3 the Python-script ("max_file_size" and 2 "git_binary_path") and mark the 1 "pre-commit"-file executable.

More Related questions