我知道如果我需要使用命令克隆一个 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/ 怎么做?
最佳答案
我找到的解决方案是将不同的 Perforce 路径克隆到不同的 Git 存储库中,然后将它们 merge 到一个新的存储库中,同时保留历史记录。
//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
merge 项目 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"
merge 项目 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
关于git 在一个 git repo 中克隆多个 p4 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25175539/