Unable to execute - Git P4 clone broken Unable to execute - Git P4 clone broken git git

Unable to execute - Git P4 clone broken


I saw this on Git for Windows 2.16.1.4 and fixed it by replacing the shebang in "C:\Program Files\Git\mingw64\libexec\git-core\git-p4".

I replaced:

#!/usr/bin/python2

with:

#!/usr/bin/env python

NOTE: depending on how git was installed, this file may instead be in

C:\Users\[USERNAME]\AppData\Local\Programs\Git\mingw64\libexec\git-core


Gabriel Morin's answer is the best for me, but it's incomplete:

  1. gitconfig is found in C:\Program Files\Git\mingw64\etc.
  2. if you get python.exe 'c:\program files\Git\mingw64\libexec\git-core\git-p4': python.exe: command not found you might want to add Python to the PATH or fully specify the path of a python.exe on your machine, like this:
[alias]    p4 = !'C:\\Program Files\\Python27\\python.exe' 'c:\\program files\\Git\\mingw64\\libexec\\git-core\\git-p4'
  1. even so you might get something like: failure accessing depot: could not connect which is either because you use the interactive p4 interface and you don't have the environment variables that allow you to connect to perforce from the command line (see if p4 sync works for you) and set :
p4 set P4PORT=<server>:1666p4 set P4USER=<user>p4 set P4PASSWD=<password>p4 set P4CLIENT=<some name>
  1. git-p4.py does NOT work with Python 3.0. You need to install Python 2.7.3 or whichever is highest.


It's not that complicated really, at least as of October 2017:

I installed Python 2.7.x for Windows, Git for Windows 2.14.2, and Perforce command line tools. I put all three on my path and tested that I was able to call python, git and p4 from the command line. Then I was able to add this to my gitconfig:

[alias]    p4 = !python.exe 'c:\\program files\\Git\\mingw64\\libexec\\git-core\\git-p4'

Then using git p4 from the command line worked.