3

I'm improving some legacy codes, and I use git to handle versions. And I found another branch of the SAME legacy codes, so I want to merge it to my codes. The question is: the initial commits of these two versions are different, so I can't simply rebase in git.

NOW:
(origin) -- (untracked modifications) -- my tracked improvements 
         \- (other untracked modifications) --some other tracked improvements 
NEEDED:
(origin) -- some other tracked improvements -- my tracked improvements

As in the graph, the two branches are in 2 individual repositories.

I think what I need maybe just import all the changed into another new repository, but I don't know how.

Haocheng
  • 1,323
  • 1
  • 9
  • 14

1 Answers1

1

If you have 2 very similar repos, you could use graft points in order to make a commit of one repo the parent of the other repo, allowing you to rebase after that.
You have an example with "How to merge two branches without a common ancestor?", but you would need a git filter-branch to make what is a local modification (graft point) permanent.

Another more classic solution would be to use subtree merging (also presented in the Pro Git book).

The blog post "Having Fun with Git Subtree" gives you an example of such a merge between two repo.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @Haocheng: excellent. Can you post as an answer the solution you choosed (graft or subtree merge?) and the commands you typed to achieve what you wanted? – VonC Jan 11 '12 at 07:03