The default installation of msysgit (aka the official git client for Windows) is unfortunately built without python support. There are understandable reasons as to why this is, starting with “where the heck do I find the various python versions on Windows”. For me the problem was that I needed git-p4 to extract some code history out of a Perforce repository and guess what, git-p4 is written in Python. Only solution for me was that I had to find a way to make this work short of throwing Linux in a VM just to get a git import going.

It actually turned out to be fairly simple. The git-p4 that comes with the msysgit installation is a very basic placeholder that the main git executable runs via its shell. Getting the git-p4 plugin to work was a simple case of dropping the “real” from the Linux distribution into an appropriate location and then modifying git-p4 to run my local python with the appropriate command line. Just keep in mind that the shell used by msysgit is a unix shell so you need to make sure that the paths and parameters are in /bin/sh syntax and not in DOS batch syntax. Here’s my current hacked version of git-p4 that seems to do the job:


c:/python27/python “c:/program files (x86)/Git/libexec/git-core/” $1 $2 $3 $4 $5 $6 $7 $8 $9

One thought on “How to enable (hack) git-p4 in msysgit for Windows”

  1. Thank you Timo! I’ve made the following small alteration locally to make sh pass all arguments to That way, if git ever needs to pass more than 9 arguments to, things will still work:


    “c:/python27/python” “c:/program files (x86)/Git/libexec/git-core/” “$@”

    Cheers, and many thanks for this simple workaround!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.