连接两个Git存储库的历史? [英] Concatenate the history of two Git repositories?

查看:118
本文介绍了连接两个Git存储库的历史?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个旧的Git仓库,称它为 app 。然后,一年后,我想从头开始重建应用程序,所以我做了一个新的回购,称之为 app-2



现在,我意识到我应该创建一个新的分支或其他东西,而不是新的回购,因为我想移动 app-2 app 之上,然后去掉 app-2 ,这样 app 现在具有 app + app-2 的所有历史记录。



这是可能的吗?

更新:

通过删除 app 中的所有文件( .git除外),重置 app 目录)并进行提交。然后:

  cd〜/ Projects / app-2 
git format-patch --stdout --root master> ; ../app/app-2-patches.txt
cd ../app
git am app-2-patches.txt

但是,我在 app-2 中有分支的地方遇到冲突。



是否可以应用来自 app-2 的提交,同时保留 app-2的历史记录的分支结构

解决方案

你可以使用git的移植点。首先将应用程序的历史记录从遥控器拖入 app-2 中,然后按照说明进行操作。在这个答案中。


I have an old Git repo, call it app. Then, after a year, I wanted to rebuild the app from scratch, so I made a new repo, call it app-2.

Now, I realize I should've just made a new branch or something, instead of a new repo, because I want to move the history of app-2 on top of app and then get rid of app-2 so that app now has all the history of app + app-2.

Is this possible to do?

UPDATE:

I tried "reseting" the app repo by removing all the files in app (except for the .git directory) and making a commit. Then:

cd ~/Projects/app-2
git format-patch --stdout --root master > ../app/app-2-patches.txt
cd ../app
git am app-2-patches.txt

But, I got conflicts in places where I had branches in app-2.

Is it possible to apply the commits from app-2 while keeping the branch structure of the history of app-2?

解决方案

You can use git's graft points for this. First pull the history of app into app-2 from a remote, then follow the instructions e.g. in this answer.

这篇关于连接两个Git存储库的历史?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆