git clone multiple p4 paths in one git repo

前端 未结 2 467
后悔当初
后悔当初 2021-01-05 05:50

I know that if I need to clone a perforce an existing p4 repository using command

git p4 clone //depot/path/project

But what if I want to m

2条回答
  •  醉梦人生
    2021-01-05 06:23

    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/...
    

    Clonning Perforce repository into git:

    git p4 clone //depot/Projects/A@all
    git p4 clone //depot/Projects/C@all
    

    Then create an empty Git repository:

    mkdir project
    cd project
    git init
    

    Add repositories path:

    git remote add -f a ../A
    git remote add -f c ../C
    

    Merge Project A:

    git merge --allow-unrelated-histories a/master
    

    Move Project A into a subdir:

    mkdir dir_a
    find . -maxdepth 1 -not -name ".git" -and -not -name "dir_a" -exec git mv {} dir_a/ \;
    

    Commit changes:

    git commit -m "Merge Project A"
    

    Merge Project 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"
    

    Using Git:

    $ git --version
    git version 2.14.1
    

提交回复
热议问题