如何在 Windows 中运行 git-p4?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2646380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How does one run git-p4 in Windows?
提问by Michael Brennan
It doesn't look like git-p4 is part of the MSys-Git project for Windows. Does anybody know how to get it running through Windows?
它看起来不像 git-p4 是 Windows 的 MSys-Git 项目的一部分。有谁知道如何让它通过 Windows 运行?
回答by VonC
Update July 2019, the "Git P4 clone broken" question now mentions by Gabriel Morin:
2019 年 7 月更新,Gabriel Morin现在提到了“ Git P4 克隆损坏”问题:
[alias]
p4 = !python.exe 'c:\program files\Git\mingw64\libexec\git-core\git-p4'
Then using
git p4
from the command line worked.
然后
git p4
从命令行使用工作。
Update March 2020
2020 年 3 月更新
With Git 2.27 (Q2 2020), "git p4
" is updated to work with Python 3.
在 Git 2.27(2020 年第 2 季度)中,“ git p4
”更新为可与 Python 3 一起使用。
See commit 6bb40ed(23 Jan 2020) by SZEDER Gábor (szeder
).
See commit 7575f4f, commit ce425eb, commit 2e2aa8d, commit a6b1306, commit 4294d74, commit 50da1e7, commit 5a5577d, commit d38208a, commit 86dca24, commit 6cec21a, commit 1f8b46d, commit 0b4396f(13 Dec 2019) by Yang Zhao (yangminz
).
See commit 484d09c(13 Dec 2019) by Ben Keene (seraphire
).
(Merged by Junio C Hamano -- gitster
--in commit 9a0fa17, 25 Mar 2020)
请参阅SZEDER Gábor ( )提交的 6bb40ed(23 Jan 2020 )。
见提交7575f4f,提交ce425eb,提交2e2aa8d,提交a6b1306,提交4294d74,提交50da1e7,提交5a5577d,提交d38208a,提交86dca24,提交6cec21a,提交1f8b46d,提交0b4396f(2019年12月13日),由杨钊()。
请参阅Ben Keene ( ) 的commit 484d09c(2019 年 12 月 13 日)。szeder
yangminz
seraphire
(由Junio C gitster
Hamano合并-- --在2020 年 3 月 25 日提交 9a0fa17 中)
ci
: use python3 in linux-gcc and osx-gcc and python2 elsewhereSigned-off-by: SZEDER Gábor
Python2 reached end of life, and we have been preparing our Python scripts to work with Python3.
'
git p4
', the main in-tree user of Python, has just received a number of compatibility updates.
ci
: 在 linux-gcc 和 osx-gcc 中使用 python3 以及在其他地方使用 python2签字人:SZEDER Gábor
Python2 的生命周期结束了,我们一直在准备 Python 脚本以与 Python3 一起使用。
“
git p4
”,Python 的主要树内用户,刚刚收到了一些兼容性更新。
Update July 2018:
2018 年 7 月更新:
Git 2.19 (Q3 2018) will start bringing Python 3 support to git p4.
Git 2.19(2018 年第三季度)将开始为 git p4 提供 Python 3 支持。
See commit db2d997, commit f2606b1, commit efdcc99, commit 4d88519, commit dba1c9d, commit fc35c9d(19 Jun 2018) by Luke Diamand (luked99
).
(Merged by Junio C Hamano -- gitster
--in commit 6dcd364, 18 Jul 2018)
见提交db2d997,提交f2606b1,提交efdcc99,提交4d88519,提交dba1c9d,fc35c9d提交(2018年6月19日)由卢克DIAMAND( )luked99
。
(由Junio C gitster
Hamano合并-- --在提交 6dcd364 中,2018 年 7 月 18 日)
Code preparation to make "git p4" closer to be usable with Python 3.
代码准备使“git p4”更接近于与 Python 3 一起使用。
Update January 2016:
2016 年 1 月更新:
Since 2010, contrib/fast-import/git-p4.README
mentions since April 2012
自 2010 年以来,contrib/fast-import/git-p4.README
自 2012 年 4 月起提及
The git-p4 script moved to the top-level of the git source directory. Note that the top-level git-p4.py script is now the source
git-p4 脚本移到了 git 源目录的顶层。请注意,顶级 git-p4.py 脚本现在是源
Windows users can copy the
git-p4.py
source script directly, possibly invoking it through a batch file called "git-p4.bat
" in the same folder.
It should contain just one line:
Windows 用户可以
git-p4.py
直接复制源脚本,也可以通过git-p4.bat
同一文件夹中名为“ ”的批处理文件来调用它。
它应该只包含一行:
@python "%~d0%~p0git-p4.py" %*
(Although this 2013 article is invoking git-p4.py
directly)
(虽然这篇2013年的文章是git-p4.py
直接调用的)
Original answer (April 2010)
原始答案(2010 年 4 月)
As mention in "Why Perforce is more scalable than Git", be careful to not import in Git anyp4 repo. Git cannot handle the same kind of huge unique repo P4 can manage.
正如“为什么 Perforce 比 Git 更具可扩展性”中提到的,小心不要在 Git 中导入任何p4 存储库。Git 无法处理 P4 可以管理的那种巨大的独特的 repo。
Git-P4 being in Python, it should run on Windows (like in this question)
Git-P4 在 Python 中,它应该在 Windows 上运行(就像在这个问题中)
You can grab git-p4.py hereand use this as git-p4.bat
您可以在此处获取 git-p4.py并将其用作 git-p4.bat
@python "%~d0%~p0git-p4" %*
It requires a Python 2.x installed.
它需要安装 Python 2.x。
Don't forget there is another approach as well.
不要忘记还有另一种方法。
回答by Tao
The simplest answer I found, and seems to work flawlessly so far, was on Timo Geusch's blog:
我找到的最简单的答案是Timo Geusch 的博客,到目前为止似乎完美无缺:
- Make sure you have Python 2.X installed, eg in
C:\Python27
(dunno if git-p4 supports Python 3, so I didn't risk itgit-p4.py does not support Python 3.X, as of March 2014) - Get a copy of git-p4.py from anywhere, eg as Eric Lathrop's blog post suggests, from the git repodirectly (I got mine from a linux install of git 2.1 that I happened to have already set up)
- In your MSysGit installation, navigate to
libexec\git-core
, eg on my Git for Windows 1.9.4-preview20140611 install on windows 7 64-bit that isC:\Program Files (x86)\Git\libexec\git-core
- Drop your git-p4.py file there
At that same location, edit the "git-p4" extensionless file, replacing the dummy echo and exit lines with a single line
c:/python27/python "c:/program files (x86)/Git/libexec/git-core/git-p4.py" $1 $2 $3 $4 $5 $6 $7 $8 $9
- 确保你安装了 Python 2.X,例如
C:\Python27
(不知道 git-p4 是否支持 Python 3,所以我没有冒险git-p4.py 不支持 Python 3.X,截至 2014 年 3 月) - 从任何地方获取 git-p4.py 的副本,例如 Eric Lathrop 的博客文章所建议的,直接从git repo(我从 git 2.1 的 linux 安装中获得我的,我碰巧已经设置了)
- 在您的 MSysGit 安装中,导航到
libexec\git-core
,例如在我的 Git for Windows 1.9.4-preview20140611 install on windows 7 64-bit 上C:\Program Files (x86)\Git\libexec\git-core
- 将您的 git-p4.py 文件放在那里
在同一位置,编辑“git-p4”无扩展名文件,用单行替换虚拟 echo 和 exit 行
c:/python27/python "c:/program files (x86)/Git/libexec/git-core/git-p4.py" $1 $2 $3 $4 $5 $6 $7 $8 $9
That's it. git-p4 now works on your MSysGit / Git for Windows installation just like it does on any linux box.
就是这样。git-p4 现在可以在您的 MSysGit / Git for Windows 安装上工作,就像在任何 linux 机器上一样。
(please note, Eric Lathrop's existing answerhas a lot of additional information about working with git-p4 and all its limitations; I thought this question could benefit from a simple howto answer to the actual question though, i.e. easily getting it working on Windows, lest more wanderers be discouraged as I was last week)
(请注意,Eric Lathrop 的现有答案有很多关于使用 git-p4 及其所有限制的附加信息;我认为这个问题可以从一个简单的如何回答实际问题中受益,即很容易让它在 Windows 上工作,以免更多的流浪者像上周一样灰心)
回答by Eric Lathrop
I got it to work, but it was a long, arduous process, fraught with peril. I wrote up the instructions on my blog: http://ericlathrop.com/2012/12/how-to-set-up-git-p4-in-windows/
我让它开始工作,但这是一个漫长而艰巨的过程,充满了危险。我在我的博客上写了说明:http: //ericlathrop.com/2012/12/how-to-set-up-git-p4-in-windows/
回答by Colonel Panic
After reading https://git-scm.com/docs/git-p4
阅读后https://git-scm.com/docs/git-p4
py -2 "C:\Program Files\Git\mingw64\libexec\git-core\git-p4" clone //Projects/App/@all
Worked for me
对我来说有效