Is it possible to combine two identically structured git repositories when they have never had a common history?

I have two small git repositories. Projects started from different points, but converged to very similar ones (identical file names, folder structure, etc.). One is not a branch of the other, but can be considered the evolution of the other.

It would be nice if I could combine the two, so repo2 is a continuation of repo1 . Is this possible by adding repo2 history to the end of repo1 's?

+7
git merge repository
mar 16 '09 at 18:10
source share
1 answer

You can extract one into the other :

 $ cd project1 $ git config remote.project2.url /path/to/project2 $ git config remote.project2.fetch 'refs/heads/*:refs/project2/*' $ git fetch project 

This will give you two (or more) branches containing the history of project1 and project2. They are still completely independent, just use the same store of objects.

Then (not tested) you could use the graft file ( .git/info/grafts ), where you could overwrite the parental control of the commit (for example, the first of the projects2, which has the last of the projects1 for the parent)

As Dustin says in the comments, in order to “make it permanent,” reordering occurs by replaying project2 to project1.




You have another illustration in this section Using Git Inside a Project (Deployment) is a “blog post, especially the section“ How to Make Friends and Influence People ”. Again:

 git checkout two_point_ooh git remote add strelau git://gitorious.org/ruby-on-rails-tmbundle/mainline.git git checkout -b strelau/two_point_ooh git pull strelau two_point_ooh 

is a similar process, but for repositories that are forked (which is not quite so)

+7
Mar 16 '09 at 18:30
source share



All Articles