简体   繁体   中英

Append git repo to original repo

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.

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

You can graft one history onto the other by replace ing 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM