Moving a Perforce project to GitHub

June 02, 2009 at 08:41 PM | categories: Uncategorized | View Comments

I keep all of my home projects in a local Perforce instance. I wanted to put my Lisp compiler code onto GitHub; since I'm not paying for a Perforce licence, I'm limited to a single user.

The GitHub user account and repository setup process was pretty straightforward, until it came to adding files. I haven't been able to find a single set of instructions for this, but I pieced it together thanks to Stack Overflow:

  1. You will need the git-p4 Python script from here: http://repo.or.cz/w/git.git?a=tree;f=contrib/fast-import;hb=HEAD
  2. From the some empty directory -- not the one that contains the Perforce project -- run the following command to import the entire Perforce version history:
    python git-p4 clone --destination=. //depot/path/to/project/...@all
  3. You now have a brand new local git repository that contains a clone of the project from Perforce. You need to push it to GitHub:
    git remote add origin git@github.com:username/repository.git
    git push origin master
  4. To push subsequent Perforce changes to GitHub:
    git-p4 sync
    git push origin master

Edit: I almost forgot to include the URL of the compiler source

Edit 2: Turns out you mustn't run git commands from a Perforce local directory: as always, Perforce doesn't like it if something else (in this case git) interferes with its local files.

blog comments powered by Disqus