Lewis
June 3, 2025, 10:08am
1
Looking for help in migrating from Perforce to Git. I’m new to git.
I am running Windows 11 and using the following command line for Perforce various depots paths, to varying levels of success:
git p4 clone --detect-branches --import-labels depot_path@all
Issues:
Although git p4 console output appears to show the labels being imported – they do not seem to be in the git repository
Branches do not appear to be imported. The git console output shows them being imported but my output directory only contains a .git folder. However, the branch names appear as 1K files in the .git\refs\remotes\p4 and .git\logs\refs\remotes\p4 directories.
In another case when branches not imported … Perforce depot structure example
git p4 clone --detect-branches --import-labels \depot\Test@all
git console output showed all branches being imported. However my output directory only contains .git, A1 and A2 folders.
Any help much appreciated.
Thanks
Command Used:
git p4 clone --detect-branches --import-labels //depot/Test@all
Problems You’re Seeing:
No visible branches or files except .git
and a few folders.
Labels shown in output but not visible in Git.
Only some folders like A1
, A2
appear, rest missing.
What’s Actually Happening:
git p4
does import branches and labels , but:
Branches are in refs/remotes/p4/
– you need to create local branches from them.
Labels go into Git as tags but may not show if Perforce labels don’t map cleanly.
What You Need To Do (Step-by-Step):
After cloning:
Go into the .git
directory with branches stored in:
.git/refs/remotes/p4/
Create local branches manually:
Run this for each branch:
git checkout -b mybranch p4/mybranch
Or to list and automate:
for b in $(git for-each-ref --format='%(refname:strip=3)' refs/remotes/p4/); do
git branch "$b" "p4/$b"
done
To see tags (labels):
Run:
git tag
If no tags appear, it means:
Labels didn’t match any commit exactly
Or --import-labels
had no effect due to label format in Perforce
Tips:
Use --verbose
or --debug
if something seems off.
If depot structure is deeply nested (like Test/A/A1), you may need to flatten or script the import.
git p4 sync
can be used later to pull updates.
Summary:
Issue
Fix/Explanation
Branches not visible
Checkout manually from refs/remotes/p4/*
Labels not visible
May not map correctly; check with git tag
Only .git
seen
Normal for empty checkout; branches are inside .git
Complex structure
Handle per subfolder if needed or script imports
Let me know if you want a script to automate these steps.