Append git repo to original repo

24 views Asked by At

I have the following situation:

I have an old git repo, that I at one point abandoned because I started using Bazaar instead, mainly because I wanted to use LaunchPad. At the time, it was not possible to convert the original git repo to bzr format, so I simply started a new bzr repo based on the last git commit.

Now, years later, I have reversed my decision, and I want to go back to git. I have converted my bzr repo to git, but now I'd like to stack the new repo on the old one, so I have the entire 10+ years of history for the project. The first commit in the "new" repo is very similar to the last commit in the "old" repo.

I have researched how to merge git repositories, but the cases people describe are mostly merging subtrees. That is not what I want. I merely want to stack the "new" repo on top of the "old" repo.

I suppose it is possible to manually extract every commit in the "new" repo and committing them on the "old" repo, preserving the date and commit message, but I am wondering if there's a smarter way to do it.

1

There are 1 answers

0
David Deutsch On

You can do this sort of grafting with the replace command. From the Git book:

You can graft one history onto the other by replaceing the earliest commit in the new line with the latest commit on the older one. This is nice because it means that you don’t actually have to rewrite every commit in the new history, as you would normally have to do to join them together (because the parentage affects the SHA-1s).