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
- Git Software To be installed in Windows server
- Python 2.7 Or Latest
- Perforce command line tools Or p4 command
- Source Depot Path
Install them one by one and proceed with below process, Verify python, P4 and Git installation status by typing below commands.
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\git-p4.py 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
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 user.name "Administrator" git config --global user.email "firstname.lastname@example.org"
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 http://192.168.2.5:7990/scm/per/perforce_clone.git
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 http://192.168.2.5:7990/scm/per/perforce_clone.git 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 http://192.168.2.5:7990/scm/per/perforce_clone.git 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.
Thanks for your wonderful Support and Encouragement