HowTo Migrate Perforce Depot To Git Or Bitbucket git-p4

git-p4 python script is a great way to clone your existing perforce depot and migrate perforce depot to Git Or Bitbucket. It’s such a easy and simple way to do it.  In this scenario my environment is below

  • Perforce Depot’s are located in windows Server 2008 R2
  • Bitbucket and Git Installed in New and Fresh Linux machine

Going to clone Windows perforce depot and updating to Bitbucket repository.

How To Migrate Perforce Depot To Git


  1. Git Software To be installed in Windows server
  2. Python 2.7 Or Latest
  3. Perforce command line tools Or p4 command
  4. Source Depot Path

Install them one by one and proceed with below process, Verify python, P4 and Git installation status by typing below commands.


Checking Status of Python, p4 and git

OK, Now your ready to do the perforce depot clone to Git or Bitbucket

Download git-p4 python script/utility

Create one directory as destination where you will clone your perforce repository in example: f:/Depotclone

Clone Depot Locally using git-p4

Go To Start –> Run –> cmd

F:\Depotclone>c:\Desktop\ clone "//depot/Main/Test/Test/" f:\Depotclone
Importing from //depot/Main/Test/Test/ into f:\Depotclone
Initialized empty Git repository in F:/Depotclone/.git/
Doing initial import of //depot/Main/Test/Test/ from revision #head into refs/remotes/p4/master
Checking out files: 100% (7556/7556), done.

By doing to this you will get latest clone data from Perforce

Then Open git-bash from the directory where you have the clone

git bash

git bash

Push to Git or Bitbucket

You have an empty repository

To get started you will need to run these commands in your terminal where git install in this scenario Linux Server

New to Git? Learn the basic Git commands
Configure Git for the first time

git config --global "Administrator"
git config --global ""

Working with your repository
I just want to clone this repository

If you want to simply clone this empty repository then run this command in your terminal.

git clone

My code is ready to be pushed

If you already have code ready to be pushed to this repository then run this in your terminal.

cd f:\Repopath
git init
git add --all
git commit -m "Initial Commit"
git remote add origin
git push -u origin master

My code is already tracked by Git

If your code is already tracked by Git then set this repository as your “origin” to push to.

cd f:\Depotclone
git remote set-url origin
git push -u origin --all
git push origin --tags

That’s it. You successfully migrate perforce depot to git Or Bitbucket git-p4 python script

Note: By doing this activity you will not get Perforce history to Git Or Bitbucket. To Get complete perforce code history use git fusion.

Related Articles

Latest Git on Centos

Complete Linux tutorial

Thanks for your wonderful Support and Encouragement

Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

Leave a Reply

Your email address will not be published. Required fields are marked *