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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With