看起来git-p4不是Windows的MSys-Git项目的一部分。 有没有人知道如何在Windows上运行它?
看起来git-p4不是Windows的MSys-Git项目的一部分。 有没有人知道如何在Windows上运行它?
更新于2019年7月,现在Gabriel Morin提到了 "Git P4 clone broken" 问题:
[alias]
p4 = !python.exe 'c:\\program files\\Git\\mingw64\\libexec\\git-core\\git-p4'
git p4
就可以了。
在 Git 2.32 (2021年第二季度) 中,git p4
学会更高效地查找分支点。
参见 commit 6b79818,commit c3ab088 (2021年5月5日),由 Joachim Kuebart (jkuebart
) 提交。
(合并于 commit e289f68,2021年5月14日,由 Junio C Hamano -- gitster
-- 审核)
git-p4
:加速搜索分支的父级签署者:Joachim Kuebart
协助者:Junio C Hamano
协助者:Luke Diamand
For every new branch that
git-p4
imports, it needs to find the commit where it branched off its parent branch.
Whilep4
doesn't record this information explicitly, the first changelist on a branch is usually an identical copy of the parent branch.The method
searchParent()
tries to find a commit in the history of the given "parent" branch whose tree exactly matches the initial changelist of the new branch, "target
".
The code iterates through the parent commits and compares each of them to this initial changelist usingdiff-tree
.Since we already know the tree object name we are looking for, spawning
diff-tree
for each commit is wasteful.Use the "
--format
" option of "rev-list
" to find out the tree object name of each commit in the history, and find the tree whose name is exactly the same as the tree of the target commit to optimize this.This results in a considerable speed-up, at least on Windows.
On one Windows machine with a fairly large repository of about 16000 commits in the parent branch, the current code takes over 7 minutes, while the new code only takes just over 10 seconds for the same changelist:Before:
$ time git p4 sync Importing from/into multiple branches Depot paths: //depot Importing revision 31274 (100.0%) Updated branches: b1 real 7m41.458s user 0m0.000s sys 0m0.077s
After:
$ time git p4 sync Importing from/into multiple branches Depot paths: //depot Importing revision 31274 (100.0%) Updated branches: b1 real 0m10.235s user 0m0.000s sys 0m0.062s
2020年3月更新
Git 2.27(2020年第二季度)更新了"git p4
"以与Python 3兼容。
查看commit 6bb40ed(2020年1月23日)由SZEDER Gábor (szeder
)提交。
查看commit 7575f4f, commit ce425eb, commit 2e2aa8d, commit a6b1306, commit 4294d74, commit 50da1e7, commit 5a5577d, commit d38208a, commit 86dca24, commit 6cec21a, commit 1f8b46d, commit 0b4396f(2019年12月13日)由Yang Zhao (yangminz
)提交。
查看commit 484d09c(2019年12月13日)由Ben Keene (seraphire
)提交。
(由Junio C Hamano -- gitster
--在commit 9a0fa17中合并,于2020年3月25日)
ci
:在linux-gcc和osx-gcc中使用python3,在其他地方使用python2签名:SZEDER Gábor
Python2已经终止生命周期,我们一直在准备将Python脚本与Python3配合使用。
'git p4
',作为主要的内部用户,刚刚收到了许多兼容性更新。
这仅在Git 2.30(2021年第1季度)中记录在commit 263dc0中。
2018年7月更新:
Git 2.19 (2018年第三季度)将开始为git p4引入Python 3支持。
查看commit db2d997, commit f2606b1, commit efdcc99, commit 4d88519, commit dba1c9d, commit fc35c9d (2018年6月19日) 由 Luke Diamand (luked99
) 提交。
(由 Junio C Hamano -- gitster
-- 合并于 commit 6dcd364,2018年7月18日)
2016年1月更新:
自2010年以来,contrib/fast-import/git-p4.README
提到自2012年4月起。
git-p4脚本已移动到git源目录的顶层。 请注意,顶级git-p4.py脚本现在是源代码。
Windows用户可以直接复制
git-p4.py
源脚本,可能需要通过同一文件夹中名为"git-p4.bat
"的批处理文件调用。
它应该只包含一行:
@python "%~d0%~p0git-p4.py" %*
原始回答(2010年4月)
如 "为什么Perforce比Git更具可伸缩性" 中所述,请注意不要在 Git 中导入 任何 p4 存储库。Git 无法处理 P4 可以管理的同一类型的巨大唯一存储库。
由于 Git-P4 是用 Python 编写的,因此它应该可以在 Windows 上运行(例如在 这个问题 中)
您可以在此处获取 git-p4.py 并将其用作 git-p4.bat
@python "%~d0%~p0git-p4" %*
需要安装 Python 2.x。
不要忘记还有另一种方法。
[alias]
部分让我有了一些进展,但是git p4
的命令行似乎没有很好的文档记录。git p4 clone //depot/mainline/...@all c:\path\to\git\clone
似乎已经起作用了... - Jakegit-p4
,并将其命名为git-p4.py
,但这可能是不必要的。 - Jake我找到的最简单的答案,并且目前似乎完美无缺,来自Timo Geusch的博客:
C:\Python27
中(截至2014年3月,git-p4.py不支持Python 3.X,因此我没有冒险尝试)libexec\git-core
,例如在我的Windows 7 64位上安装的Git for Windows 1.9.4-preview20140611中,它是C:\Program Files (x86)\Git\libexec\git-core
在同一位置,编辑“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
就这样。现在在您的MSysGit / Git for Windows安装上,git-p4可以像在任何Linux系统上一样工作。
(请注意,Eric Lathrop的现有答案提供了大量关于使用git-p4及其所有限制的其他信息;但我认为该问题可以从一个简单的howto回答中受益,即轻松在Windows上使其工作,以免更多的漫游者像我上周一样感到沮丧)
python 2to3.py -w git-p4.py
(假设_2to3.py_和_git-p4.py_都在当前目录中)。 - user1364368我成功地让它工作了,但这是一个漫长而艰苦的过程,充满了危险。我在我的博客上写了说明:http://ericlathrop.com/2012/12/how-to-set-up-git-p4-in-windows/
阅读完https://git-scm.com/docs/git-p4后
py -2 "C:\Program Files\Git\mingw64\libexec\git-core\git-p4" clone //Projects/App/@all
对我有用
git
命令行所做的一切,但最好还是将其设置为使用文档化的 CLI。 - Jake