使用git-p4克隆部分Perforce Repo [英] Cloning a Partial Perforce Repo with git-p4
问题描述
git-p4文档提到您可以执行 - // depot / main / ignore
切换到过滤目录。这将等同于运行 git filter-branch
来删除克隆后的相同目录吗?
git p4 clone
之前,可以使用 p4
设置适当的客户端视图。有没有人有完整的细节?Perforce clientspec确定Perforce存储库的哪些部分可见(并将同步)到Perforce客户端。 clientspec还提供了从Perforce存储库路径到本地路径的映射。
您可以通过有选择地包含部分Perforce存储库来修剪Perforce客户端:
// depot / main / path1 / ... // your-perforce-client / main / path1 / ...
// depot / main / path2 / ... // your-perforce-client / main / path2 / ...
只包含 // depot / main / path1 /
和 // depot / main / path2 /
和不是 // depot / main / path3 /
。正如你所指出的,你也可以明确地排除路径:
// depot / main / path1 / ... // your-perforce-client / main / path1 / ...
- // depot / main / path1 / foo / ... // your-perforce-client / main / path1 / foo / ...
将包含 // depot / main / path1 / $ c $中的所有内容除了在
foo
子目录下的文件之外的其他文件。
取决于Perforce存储库(或排除),您可能直接告诉 git-p4
直接导入Perforce树的哪些部分:
git p4 clone --destination = / path / to / new / git / tree // depot / path1 // depot / path2
如果您想使用排除项,或者如果您想调整Perforce软件仓库路径映射到本地路径的方式,需要添加 - use-client-spec
选项。您可以通过在Git树的父目录中创建 .p4config
文件来配置应使用哪个Perforce客户端,该文件包含:
P4CLIENT = .p4config
然后设置一个环境变量:
P4CONFIG = .p4config
这样做会导致 p4
在当前目录中寻找 .p4config
文件(然后逐步搜索父目录)以获取Perforce配置数据。
要导入的文件将是Perforce包含的路径路径clientspec以及在 git p4 clone
命令行中显式提供的路径。
code> git-p4 clone 确实可以通过在 -
之前加上路径来排除路径,但是我不建议这样做,因为这意味着那些路径将仅在最初的入口处被排除RT。如果将来在Perforce中触及那个路径中的文件,执行 git p4 rebase
/ git p4 sync
将会启动那些改变了的文件(除非你记得在命令行中明确地排除它们)。但是,最初使用 --use-client-spec
导入会在 .git / config
中设置一个标志,允许它将在未来使用 git p4 rebase
/ git p4 sync
时自动兑现。)
有一点需要注意的是,如果有一天想要包含Perforce存储库的其他部分,执行选择性克隆会增加额外的复杂性。请参阅我对在初始克隆后扩展 git-p4
clientspec的回答如果你需要这样做。
What is the proper method to do a selective import of a large Perforce repo?
The git-p4 docs mention that you can do a -//depot/main/ignore
switch to filter directories. Would this be equivalent to running a git filter-branch
to remove the same directories after a clone?
Additionally, it appears Perforce provides another feature called a "client" view. I have not used Perforce before, so I am a little unfamiliar with the usage model. My current understanding is that one would use p4
somehow to setup a proper client view before running git p4 clone
. Does anyone have the complete details?
A Perforce clientspec determines what parts of the Perforce repository are visible (and will be synced) to the Perforce client. The clientspec also provides a mapping from Perforce repository paths to local paths.
You can prune a Perforce client by selectively including parts of the Perforce repository:
//depot/main/path1/... //your-perforce-client/main/path1/...
//depot/main/path2/... //your-perforce-client/main/path2/...
will include only //depot/main/path1/
and //depot/main/path2/
and not //depot/main/path3/
. As you've noted, you also can explicitly exclude paths:
//depot/main/path1/... //your-perforce-client/main/path1/...
-//depot/main/path1/foo/... //your-perforce-client/main/path1/foo/...
will include everything in //depot/main/path1/
except files under its foo
subdirectory.
Depending on how your Perforce repository is structured and depending on what you want include (or exclude), you potentially could tell git-p4
directly which parts of the Perforce tree you want to import:
git p4 clone --destination=/path/to/new/git/tree //depot/path1 //depot/path2
If you want to use exclusions or if you want to adjust how Perforce depot paths are mapped to local paths, you will need to add the --use-client-spec
option. You can configure which Perforce client should be used by creating a .p4config
file in your Git tree's parent directory containing:
P4CLIENT=.p4config
and then setting an environment variable:
P4CONFIG=.p4config
Doing this will cause p4
to look for a .p4config
file in the current directory (and then progressively searching parent directories) for Perforce configuration data.
The files that will be imported will be the intersection of paths included by the Perforce clientspec and by the paths explicitly provided on the git p4 clone
command-line.
(As you mentioned, git-p4 clone
does allow excluding paths by prefixing them with -
. However, I do not recommend doing this because that means that those paths will be excluded only on the initial import. If files in that path are touched in Perforce in the future, performing git p4 rebase
/git p4 sync
will pick up those changed files (unless you remember to explicitly exclude them on the command-line again). Initially importing using --use-client-spec
, however, will set a flag in .git/config
that allows it to be honored automatically when using git p4 rebase
/git p4 sync
in the future.)
One caveat is that performing a selective clone will add extra complication if someday you want to include other parts of the Perforce repository. See my answer to "Extending git-p4
clientspec after initial clone" if you need to do that.
这篇关于使用git-p4克隆部分Perforce Repo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!