我如何将一个git历史追加到另一个? [英] How do I append one git history to another?

查看:112
本文介绍了我如何将一个git历史追加到另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储库,其中包含旧版网站的代码,该网站不再在 master 上使用。该网站在新的存储库中完全重新设计,并且该存储库中的代码和历史记录被复制到旧网站的存储库中的分支中,我们称之为 new_site 。我无法将 new_site 合并到 master 中,因为历史记录完全不同。

我调查了两个子模块和子树合并了一下,但两者似乎只在您试图保留来自包含在子目录另一个项目,而不是当你想把两棵工作树粘在一起时。



在这一点上,我希望旧代码保持在原来的位置,并在当前HEAD之上追加 new_site 。任何想法如何我可以做到这一点,或替代的建议,清理这个烂摊子,而不会吹走旧代码? 想法是:





从A导入了正确的分支后,您可以使用 移植点 ,然后 git filter-branch 将嫁接历史转化为真实历史,以摆脱嫁接点。

I have a repository that contains the code for an old version of a website that is no longer being used on master. The site was completely redesigned in a new repository, and the code and history from that repository was copied over into a branch in the repo of the old site, let's call it new_site. I can't merge new_site into master, since the histories are entirely different.

I've investigated both submodules and subtree merges a bit, but both seem to only be relevant when you're trying to keep code from one project contained in a subdirectory of another project, not when you want to stick two working trees on top of each other.

At this point, I would like to have the old code remain where it is, and just append new_site on top of the current HEAD. Any idea how I can accomplish this, or alternate suggestions for cleaning up this mess without blowing away the old code?

解决方案

The general idea is:

Once you have imported the right branch from A, you can use graft point, and then git filter-branch to turn a grafted history into "real" history, to get rid of the graft point.

这篇关于我如何将一个git历史追加到另一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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