Search code examples
gittfstfvcgit-tfs

How to append a git repository on top of another


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

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.

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

I want to have

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

Solution:

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

Solution

  • 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.