Tuesday, December 2, 2014

Perforce to GIT migration with history

Here are the step by step guide to migrate from Perforce to GIT with history ..

  • Install git-p4 : Refer http://answers.perforce.com/articles/KB_Article/Git-P4 , in the end of this URL follow step 2 to Step 4
  • Sync the code from Perforce to a workspace (P4CLIENT).
  • Create a .p4config file with the P4PORT, P4USER & P4CLIENT values in $HOME
         cat .p4config
           P4PORT= 
           P4USER=
           P4CLIENT=
  • mkdir git-migration-root/component
  • cd  git-migration-root/component
  • cp $HOME/.p4config .
  • unset SSH_ASKPASS  # This will disable the git command attempt to open xterm. It is needed if you invoke the below command from putty.
  • git p4 clone //depot/component@all . 
        The above step will clone the code from Perforce Workspace ( with reference to .p4config P4CLIENT value). 
         In the above command "@all" option will copy the entire history. If this option is ignored, only HEAD revision is copied.
  • export GIT_SSL_NO_VERIFY=true  #Disabling SSL cert verification for push command.
  • git remote add origin ${GIT_URL}/component.git #Create a remote to point to STASH/github bare repository
  • git remote set-url origin ${GIT_URL}/component.git
  • git push origin master