我知道如果我需要使用命令
克隆perforce现有的p4存储库git p4 clone //depot/path/project
但是如果我想将多个p4路径放入一个git仓库呢? 说我有以下结构
//depot---/Path1----/APath/...
| |
| |
| --/BPath/...
|
|
---/Path2----/CPath/...
|
|
---/Path3
我只想克隆 // depot / Path1 / APath / 和 // depot / Path2 / CPath / 在我的本地目录 〜/ Desktop / mylocalRepo / 怎么做?
答案 0 :(得分:3)
我找到的解决方案是将不同的Perforce路径克隆到不同的Git存储库中,然后将它们合并到一个新的存储库中,同时保留历史记录。
//depot/Projects/A
...
//depot/Projects/C
//depot/Projects/...
将Perforce存储库克隆到git:
git p4 clone //depot/Projects/A@all
git p4 clone //depot/Projects/C@all
然后创建一个空的Git存储库:
mkdir project
cd project
git init
添加存储库路径:
git remote add -f a ../A
git remote add -f c ../C
合并项目A:
git merge --allow-unrelated-histories a/master
将项目A移动到子目录中:
mkdir dir_a
find . -maxdepth 1 -not -name ".git" -and -not -name "dir_a" -exec git mv {} dir_a/ \;
提交更改:
git commit -m "Merge Project A"
合并项目C:
git merge --allow-unrelated-histories c/master
mkdir dir_c
find . -maxdepth 1 -not -name ".git" -and -not -name "dir_a" -and -not -name "dir_c" -exec git mv {} dir_c/ \;
git commit -m "Merge Project C"
使用Git:
$ git --version
git version 2.14.1
答案 1 :(得分:1)
您可以使用git-p4的--use-client-spec
选项执行此操作。请参阅"客户规范" git-p4 documentation中的部分。
使用此选项时,git-p4使用Perforce客户端视图将库路径映射到Git存储库。通过使用所需的映射设置Perforce客户端,您可以有选择地导入Perforce库的部分内容。