git-p4 clone when depot different

125 views Asked by At

I am trying to migrate perforce to git for test.

In case of me, branch hierarchy is little special.

export P4USER=xxx
p4 login
 
export P4CLIENT=mig_to_git
p4 client -o
...
View:
    //MAIN/product/... //mig_to_git/master/...
    //REL/product/v1.1/common/... //mig_to_git/rel-v1.1-common/...
 
git init
git lfs install
git config git-p4.largeFileSystem GitLFS
git config git-p4.largeFileThreshold 100m
git config git-p4.branchList master:rel-v1.1-common
git config git-p4.client mig_to_git

I create client(workspace) for using --use-client-spec option.

and I run like below.

git p4 clone --use-client-spec //MAIN/product@all //REL/product/v1.1/common@all

But it does not work. How can I do this?

1

There are 1 answers

0
Douglas Leeder On

My approach was to clone the branches separately then combine them in git.

You can use git filter-branch to re-parent the root commit on the newer branch onto the matching commit on the older branch.

This might not be suitable if you have many merges between the branches, but might be sufficient if you just have an initial fork that you want to model.

See https://labs.consol.de/development/git/2017/09/08/reunite-separate-git-repositories.html

NB: This appears to work, but I haven't actually completed the migration at this point.