Import TFS history from another project to Git

452 Views Asked by At

I'm trying to migrate a project from TFS to Git using git-tfs, on a project that inherits history from an older, not used anymore, project in TFS. Just to make things clearer: the old project has 5 years of history, then, 1 year ago the new one was created, branching from the old one.

I need to preserve every history and every branch.
Cloning multiple branches from the new project is no problem, however, I'm struggling in reading the full history of the repository.

I.e. the clone command starts reading the commits from the first one made under the new project and ignores all the old ones, coming from the previous project.

During the clone operation, I see multiple errors of commit not found, when a file links to a commit made on the previous project.

In Visual Studio, the history of each file links to the commits made in the previous project. So in Visual Studio I can see 6 years of history, instead of 1.

I can clone the old project separately without issue (cloning the previous 5 years of history), but I would like to have the two histories merged, so I can see the whole history of edits when I check the history of each file in Git.

How can I pull commits from the two VSTS projects into a single git repo?

Thanks!

1

There are 1 best solutions below

0
On

I can clone the old project separately without issue (cloning the previous 5 years of history), but I would like to have the two histories merged, so I can see the whole history of edits when I check the history of each file in Git.

If you could use git-tfs to clone the 2 histories in 2 different git repos, you could once you have the 2 repositories:

  1. In one of the repository, add a remote toward the other one
  2. git fetch --all
  3. Use git replace to link the 2 histories: https://git-scm.com/docs/git-replace#git-replace---graftltcommitgtltparentgt82308203