Migrate Perforce to git(hub) repo


  • You have done your due diligence to compare the two (from price, speed, workflow, onboarding etc. perspectives) and have concluded that reasons to migrate Perforce to git are beneficial for you.
  • Word of caution. Do you have “large files”? Well, define “large”! Some cloud vendors set some limit for what is the maximum limit of your file could you upload to the cloud. Check out this Powershell script: Powershell.P4Sizes ¬∑ GitHub


To prepare for surprises, plan ahead on how would you verify if the migration has succeeded!

  1. Make sure you or your team have unit tests written and these unit tests are working reliably, to avoid surprises in the end.
  2. You can not work with moving target. When you are ready to implement the proposed plan in this post, you would have to issue a code freeze with an immediate effect.
  3. Clean up your existing data: Delete junk branches. Ideally just keep one master branch. Delete any unnecessary files, binary files generated from builds etc. Be meticulous. Perforce might have multiple repositories. Git is different.
  4. After clean up, y’all need to make a decision. Do you care for the code commit (check-in history)? Very important step. The rest depends on it. Unless you really care about the history, you should not care about the history.
    1. If you do not care, right after the clean up, navigate to the directory where your project is. Initiate each git repository by issuing $ git init in your Windows Terminal app (or command prompt, or git bash for that matter).
    2. You could use Git-p4 or Git Fusion. Which would preserve the entire history and extracts a section of your Perfroce server onto git repository. It is painful, time consuming and requires patience, diligence but it perseveres the history. It is unlikely that your data transfers would translate 100% from code annotations, history perspective, but that is OK!
  5. Federated access to git. Start mapping user permissions etc. Perforce is notorious when it comes to permissions. You might wanna get with project leads, tech leads, Dev(Sec)Ops folks (and the whole agile team) to co-ordinate and start with simple permissions, take baby steps here – given the new project structure in git.
  6. The unit tests from step 1 up above, would come in handy at this point of time. Start testing the integrity of your git repositories.

The two options I mentioned in step 4.2:

(A) git-p4

  1. Git-p4 Usage
  2. Docs – Migrating a Perforce repository to Git (linkedin.com)
export P4USER="aarsh"
export P4PORT="tcp:perforce-server.com:12345"
p4 login
mkdir test && cd test
git-p4 clone //x@y . --verbose

(B) Git Fusion

  1. Git Fusion Guide
  2. How to migrate with Git Fusion

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s