I try to migrate a Git repository into Perforce. What I have tried is (e.g.)
git clone https://github.com/mbostock/d3.git
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?
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... :-)