Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8033621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:45:10+00:00 2026-06-05T01:45:10+00:00

I have created a little pre-commit hook in python. This hook works like a

  • 0

I have created a little pre-commit hook in python. This hook works like a charm under Linux, but in Windows it keeps telling me:

error: cannot spawn .git/hooks/pre-commit: No such file or directory

I know there have been similar questions here about the same issue and the conclusion seams to be the shebang. My script has this on the very first line:

#!F:\PortableApps\PortablePython3.2\App\python.exe

It’s also interesting to note that executing the script simply by writing .git/hooks/pre-commit works wonderful, but as soon as I try to commit, git spits out the above message.

Another interesting thing is, when I convert the encoding from ANSI to UTF-8 (using Notepad++), I get the following error when trying to execute the script:

.git/hooks/pre-commit: Cannot execute binary file

I’m using the following tools:

  • PortablePython 3.2.1.1
  • msysgit 1.7.6 (Portable)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:45:12+00:00Added an answer on June 5, 2026 at 1:45 am

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

    Here is the important part about making it work under Windows


    If you’re working with Windows (and “msysgit”), it’s a little more complicated. Since “msysgit” seems to have a problem handling the SHEBANG, you’ll have to use a little trick to make the script executable (further information on this problem can be found here).

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

    #!/bin/sh
    python .git/hooks/pre-commit.py
    

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

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

    Afterwards you’ll want to copy both the wrapper-file (“pre-commit”) and the Python-script (“pre-commit.py”) to your repos “.git/hooks”-directory, personalize the Python-script (“max_file_size” and “git_binary_path”) and mark the “pre-commit”-file executable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a multi plattform project, and everything works nicely, except one little
I have created a little Python egg (with setuptools) that I want to install
I have created a little execution timer and as an extra id like to
I have a challenge - I have created this little concept here . The
I have created a little robot like the Karel robot ( Wikipedia ) which
I have created a little example,please have a look, http://jsfiddle.net/bWTwL/ I want to have
Hi I have created a little application to move some files around and put
Ok, I have created a little utility with AppleScript and used Automator to turn
I am a little stuck. I have created almost everything in the picture below.
I have a page which contains a jQuery-UI horizontal slider, created using a little

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.