Can two identically structured git repos be merged when they have never had any common history?

隐身守侯 提交于 2019-11-30 13:22:41
VonC

You can fetch one into another:

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

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

Then (not tested), you could use a graft file (.git/info/grafts) where you could overwrite the parenthood of a commit (like the first of project2 having for parent the latest of project1)

As Dustin says in the comments, a rebase is in order in order to "make it permanent", by replaying project2 commits onto project1.


You have another illustration in this "Using Git within a project (forking around)" blog entry, especially the section "How to pull 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 which are forked (which is not exactly your case)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!