无法执行 - Git P4 克隆损坏

Unable to execute - Git P4 clone broken

安装 git 后 - 我尝试克隆现有的 p4 分支,但失败并显示以下信息:

c:\P4_GIT\DT>git p4 clone //depot/CTAT/Windows/OneP/
fatal: 'p4' appears to be a git command, but we were not
able to execute it. Maybe git-p4 is broken?

我从未遇到过 git for Windows with Python 支持(git p4 需要)。但也许我错过了什么。每次我在 Windows 上使用 git p4 时,我都会得到

> git p4
basename: too many arguments
Try `basename --help' for more information.
fatal: git was built without support for  (NO_PYTHON=YesPlease).

这也得到了证实here

但是您的错误消息不同,所以您可能 有 git 和 Python 支持。不确定...

我已经取得了更大的成功(诚然 Linux)从 github 下载 git-p4 分支之一并直接调用它 (git-p4)而不是通过 git p4.

也许这对你有帮助?

其实并没有那么复杂,至少截至 2017 年 10 月是这样:

我为 Windows 安装了 Python 2.7.x,为 Windows 2.14.2 安装了 Git,以及 Perforce 命令行工具。我将所有三个都放在我的路径上并测试了我能够从命令行调用 pythongitp4。然后我可以将它添加到我的 gitconfig:

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

然后从命令行使用 git p4

我在 Git 上看到 Windows 2.16.1.4 并通过替换 "C:\Program Files\Git\mingw64\libexec\git-core\git-p4" 中的 shebang 修复了它。

我替换了:

#!/usr/bin/python2

与:

#!/usr/bin/env python

注意:根据 git 的安装方式,此文件可能位于

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

Gabriel Morin 的回答对我来说是最好的,但不完整:

  1. git配置位于 C:\Program Files\Git\mingw64\etc。
  2. 如果你得到 python.exe 'c:\program files\Git\mingw64\libexec\git-core\git-p4': python.exe: command not found 你可能想要添加 Python PATH 或完全指定 python.exe 在您机器上的路径,如下所示:
[alias]
    p4 = !'C:\Program Files\Python27\python.exe' 'c:\program files\Git\mingw64\libexec\git-core\git-p4'
  1. 即便如此,您可能会得到类似这样的信息:访问软件仓库失败:无法连接,这可能是因为您使用交互式 p4 界面并且您没有环境变量允许您从命令行连接到 perforce(查看 p4 sync 是否适合您)并设置 :
p4 set P4PORT=<server>:1666
p4 set P4USER=<user>
p4 set P4PASSWD=<password>
p4 set P4CLIENT=<some name>

  1. git-p4.py 不适用于 Python 3.0。您需要安装 Python 2.7.3 或最高版本。