Concat two git repositories in fast-import format

Today I spent a few hours wrapping my head around the documentation of git fast-import, especially the part of restarting an incremental import from the current branch value. The documentation says it should be written as:

from refs/heads/branch^0

or, since the current branch usually is master, as

from refs/heads/master^0

There is also a short answer on nabble. But I could not find an example of how to really edit the input file.

The solution is simple:
Edit the first commit of the second input file without adding a new blank line (the file is named ‘research-git-dump.dat’ in my case).

Before:

commit refs/heads/master
mark :1000000000
committer Bubba Gump <bubba.gump@shrimps.com> 1206025332 +0000
data 6
my commit comment

M 100644 :2430 MyProject/myfile1
M 100644 :2439 MyProject/myfile2
:

After:

commit refs/heads/master
mark :1000000000
committer Bubba Gump <bubba.gump@shrimps.com> 1206025332 +0000
data 6
my commit comment
from refs/heads/master^0
M 100644 :2430 MyProject/myfile1
M 100644 :2439 MyProject/myfile2
:

Doing this, the second import went like a charm.
I was able to concat two git repositories created by cvs2git:

$ git init --bare merged.git
$ cd merged.git/
$ cat ../custom-git-blob.dat ../custom-git-dump.dat | git fast-import
$ cat ../research-git-blob.dat ../research-git-dump.dat | git fast-import
$ gitk

… and gitk was happy!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s