我知道如果我需要使用命令克隆perforce现有的p4存储库
git p4 clone //depot/path/project
Run Code Online (Sandbox Code Playgroud)
但是,如果我想将多个p4路径合并到一个git repo中怎么办?
说我有以下结构
//depot---/Path1----/APath/...
| |
| |
| --/BPath/...
|
|
---/Path2----/CPath/...
|
|
---/Path3
Run Code Online (Sandbox Code Playgroud)
我只想在本地目录〜/ Desktop / mylocalRepo /下的// depot / Path1 / APath /和// depot / Path2 / CPath /下克隆文件, 怎么办?
我找到的解决方案是将不同的 Perforce 路径克隆到不同的 Git 存储库中,然后将它们合并到新的存储库中,同时保留历史记录。
//depot/Projects/A
...
//depot/Projects/C
//depot/Projects/...
Run Code Online (Sandbox Code Playgroud)
将 Perforce 存储库克隆到 git 中:
git p4 clone //depot/Projects/A@all
git p4 clone //depot/Projects/C@all
Run Code Online (Sandbox Code Playgroud)
然后创建一个空的 Git 存储库:
mkdir project
cd project
git init
Run Code Online (Sandbox Code Playgroud)
添加存储库路径:
git remote add -f a ../A
git remote add -f c ../C
Run Code Online (Sandbox Code Playgroud)
合并项目A:
git merge --allow-unrelated-histories a/master
Run Code Online (Sandbox Code Playgroud)
将项目 A 移动到子目录中:
mkdir dir_a
find . -maxdepth 1 -not -name ".git" -and -not -name "dir_a" -exec git mv {} dir_a/ \;
Run Code Online (Sandbox Code Playgroud)
提交更改:
git commit -m "Merge Project A"
Run Code Online (Sandbox Code Playgroud)
合并项目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"
Run Code Online (Sandbox Code Playgroud)
使用 Git:
$ git --version
git version 2.14.1
Run Code Online (Sandbox Code Playgroud)
您可以使用--use-client-specgit-p4 选项来完成此操作。请参阅git-p4 文档中的“客户端规范”部分。
当您使用此选项时,git-p4 使用您的 Perforce 客户端视图将软件仓库路径映射到您的 Git 存储库。通过使用所需的映射设置 Perforce 客户端,您可以有选择地导入 Perforce 仓库的部分内容。
| 归档时间: |
|
| 查看次数: |
1272 次 |
| 最近记录: |