我正在尝试在 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'
这里出了什么问题?
我所做的事情存在一些非常根本的错误。如果有人面临类似问题,请参阅下面的评论 -
最初,全局 gitconfig 文件可能不存在于用户目录中。
在 git bash 中运行此命令以强制创建它:
git config --edit --global
然后,将其添加到 .gitconfig 文件中。 (我正在做[P4]而不是[别名])
[alias]
p4 = !'C:\\Git\\bin\\git-p4.py'
确保您能够从 git bash 运行 python 和 p4 命令。
如果您遇到任何 python 问题,请参阅此内容:Python 无法在 git bash 的命令行中工作
我在 Windows 上使用以下命令设置别名:
在路径中添加python(我本地使用的是venv)
使用以下命令添加别名:
git config alias.p4 "!python.exe 'c:\program files\Git\mingw64\libexe c\git-core\git-p4'"