如何在另一个之上附加一个git存储库 [英] How to append a git repository on top of another

查看:106
本文介绍了如何在另一个之上附加一个git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将项目从TFS转换为git,我想保留所有历史记录.

I am in the process of converting a project from TFS to git, and I want to keep all history.

问题在于,一年前TFS项目已移至TFS中. 使用git-tfs可以将两个位置都转换为git,但是现在我有两个git存储库:A和B.

The problem is that the TFS project was moved in TFS one year ago. Using git-tfs I can convert both locations to git, but now I have two git repositories: A and B.

我设法将A和B都作为不同分支放入同一个存储库中.是否可以将B中的第一次提交的父级更改为A中的最后一次提交?

I have managed to get both A and B into the same repository as different branches. Would it be possible to change the parent of first commit in B to the last commit in A?

Branch A: a -> b -> c
Branch B: d -> e -> f

我想拥有

a -> b -> c -> d' -> e' -> f'

解决方案:

git filter-branch --parent-filter 'sed "s/^\$/-p <last-commit-in-A>/"' HEAD_OF_B

推荐答案

当然,设置一个graft即可.如果对结果满意,可以执行filter-branch使其永久保存.或者,您可以将filter-branch--parent-filter一起使用.

Sure, set a graft, that does exactly that. If you are satisfied with the result you can do a filter-branch to make this permanently. Or you can use filter-branch right away with a --parent-filter.

这篇关于如何在另一个之上附加一个git存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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