1

I try to migrate a Git repository into Perforce. What I have tried is (e.g.)

  1. Cloning git clone https://github.com/mbostock/d3.git
  2. Changing directory to the new folder
  3. Submitting with git p4 submit

This fails after a short while with the error message

fatal: Not a valid object name HEAD~1036
Command failed: git cat-file commit HEAD~1036

I haven't found a Git the migration works for. I am using Git 1.9.5. What am I doing wrong?

Michael Dorner
  • 17,587
  • 13
  • 87
  • 117

2 Answers2

4

git-p4 is really designed for cloning an existing p4 repo, and then mirroring that to/from git. You're trying to create a new p4 branch, which git-p4 can't directly do. So this is a little complex.

Try the following:

1. Create an empty branch in p4 somewhere.

You'll need a client pointed at your new location, //depot/foo:

$ p4 client whatever....

You will also need to create an empty file to keep p4 happy:

$ touch P4EMPTY
$ p4 -c your_client_name add P4EMPTY
$ p4 submit -d 'Add empty file'

2. Clone it:

$ cd /path/to/git/dir
$ git p4 clone //depot/foo

3. Grab the repo you want to export:

$ git remote add mycode git://whatever.git
$ git fetch mycode
$ git checkout -b upstream mycode/master

4. Rebase it against the p4 repo:

$ git p4 rebase p4/master

5. Submit:

# We don't want to edit the commit message, so skip that part
$ git config git-p4.skipSubmitEdit true
$ P4CLIENT=your_client_name git p4 submit

Or something like that anyway... :-)

Luke
  • 589
  • 2
  • 8
1

Perforce's Git Fusion product enables Git repositories to be imported into Perforce.

Information about how to achieve this is located here:

http://www.perforce.com/perforce/doc.current/manuals/git-fusion/chapter_dyn_ngj_3l.html#section_ecm_qdq_nj

Another advantage to using Git Fusion, is that user's don't need to install anything on their machines.

Hope this helps, Jen!

P4Jen
  • 1,003
  • 6
  • 6