git在一个git repo中克隆多个p4路径 [英] git clone multiple p4 paths in one git repo
问题描述
我知道,如果我需要使用命令克隆perforce现有的p4存储库
I know that if I need to clone a perforce an existing p4 repository using command
git p4 clone //depot/path/project
但是,如果我想将多个p4路径合并到一个git repo中,该怎么办?
说我有以下结构
But what if I want to multiple p4 paths into one git repo?
say I have the following structure
//depot---/Path1----/APath/...
| |
| |
| --/BPath/...
|
|
---/Path2----/CPath/...
|
|
---/Path3
我只想克隆 //depot/Path1/APath/ 和 //depot/Path2/CPath/下的文件> 在我的本地目录中 〜/Desktop/mylocalRepo/ 怎么做?
I only want to clone files under //depot/Path1/APath/ and //depot/Path2/CPath/ in my local directory ~/Desktop/mylocalRepo/ how to do it?
推荐答案
我发现的解决方案是将不同的Perforce路径克隆到不同的Git存储库中,然后将它们合并到新的存储库中,同时保留历史记录.
The solution that I found was clonning different Perforce paths into different Git repositories and later merge them into a new repository while keeping the history.
//depot/Projects/A
...
//depot/Projects/C
//depot/Projects/...
将Perforce存储库克隆到git:
Clonning Perforce repository into git:
git p4 clone //depot/Projects/A@all
git p4 clone //depot/Projects/C@all
然后创建一个空的Git存储库:
Then create an empty Git repository:
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
这篇关于git在一个git repo中克隆多个p4路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!