在Windows上配置git p4

问题描述 投票:0回答:2

我正在尝试在 Windows 上配置 git p4。我已经安装了 git bash、python 和 p4,并且能够在 cmd 提示符下访问它们。但拿不到

git p4

命令工作。 它抛出错误 -

“致命:‘p4’似乎是一个 git 命令,但我们无法 执行它。也许 git-p4 坏了?”

Git 安装在 - C:\Git 中

Python位于-C:\Python37-32

我还将 git-p4.py 文件保存在 git 下和 \git-core 下。 另外,\git-core foler 中有一个名为 git p4 的文件。

以下是 gitconfig 下的内容:C:\Git\mingw64 tc

[http]
    sslCAInfo = C:/Git/mingw64/ssl/certs/ca-bundle.crt
    sslBackend = openssl
[diff "astextplain"]
    textconv = astextplain
[filter "lfs"]
    clean = git-lfs clean -- %f
    smudge = git-lfs smudge -- %f
    process = git-lfs filter-process
    required = true
[credential]
    helper = manager
[p4]
    p4 = !'C:\\Git\\bin\\git-p4.py'

这里出了什么问题?

git perforce
2个回答
2
投票

我所做的事情存在一些非常根本的错误。如果有人面临类似问题,请参阅下面的评论 -

  • gitconfig 文件共有三种。系统、全局和本地。您必须将上述更改添加到用户目录中的全局 gitconfig 文件 (.gitconfig) 中,而不是添加到 mingw64 tc (gitconfig) 中。

最初,全局 gitconfig 文件可能不存在于用户目录中。

在 git bash 中运行此命令以强制创建它:

git config --edit --global

了解更多信息:https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Where-system-global-and-local-Windows-Git-config-files-已保存

然后,将其添加到 .gitconfig 文件中。 (我正在做[P4]而不是[别名]

[alias]
    p4 = !'C:\\Git\\bin\\git-p4.py'

确保您能够从 git bash 运行 pythonp4 命令。

如果您遇到任何 python 问题,请参阅此内容:Python 无法在 git bash 的命令行中工作


0
投票

我在 Windows 上使用以下命令设置别名:

  1. 在路径中添加python(我本地使用的是venv)

  2. 使用以下命令添加别名:

    git config alias.p4 "!python.exe 'c:\program files\Git\mingw64\libexe c\git-core\git-p4'"

© www.soinside.com 2019 - 2024. All rights reserved.