Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to clone git-p4 repo?

Tags:

git

git-p4

Is it possible to git clone existing git p4 repository so it will be possible to use git p4 for the new repository?

Here is the usecase: I have desktop PC with full repository cloned from perforce (git p4 clone <somepath>@all) an want to clone it to laptop without touching p4 server (link to it is wery slow and laggy) an be able to commit changes to perforce. Ideally it would be great to use git clone --depth and sparse clone to reduce laptop disk usage.

like image 811
Equidamoid Avatar asked Feb 19 '15 15:02

Equidamoid


People also ask

Can you clone any git repo?

You can use Sourcetree, Git from the command line, or any client you like to clone your Git repository. These instructions show you how to clone your repository using Git from the terminal. From the repository, select the Clone button.

Does cloning repo clone all branches?

The idea is to use the git-clone to clone the repository. This will automatically fetch all the branches and tags in the cloned repository. To check out the specific branch, you can use the git-checkout command to create a local tracking branch.


2 Answers

No. git p4 works by syncing up with a Perforce checkout (it's a wrapper around some p4 commands), so you also need to have the Perforce checkout accessible.

You could clone the Git repo to your laptop, do your work, push your changes to that Git repo, and run git p4 from there when you're ready to submit your changes.

like image 72
mipadi Avatar answered Sep 28 '22 09:09

mipadi


In the original git repository you should have a directory structure under .git/refs that is similar to the following:

.git/refs/
.git/refs/heads
.git/refs/tags
.git/refs/remotes
.git/refs/remotes/p4

To fetch the p4 information the following line must be added to the [remote "origin"] entry in the cloned repository:

    fetch = +refs/remotes/p4/*:refs/remotes/p4/*

This can also be achieved by running the following command inside the cloned repository:

git config --add remote.origin.fetch '+refs/remotes/p4/*:refs/remotes/p4/*'

Note: the fetch entries matches the directory structure above, so you need to confirm if yours is the same. Look here for more information on refspecs.

At this point it's just a matter of running git fetch and from this moment onward all git p4 commands should work as usual.

like image 23
Vitor Avatar answered Sep 28 '22 07:09

Vitor