Using git tf to migrate code between TFS servers retaining history

Martin Hinshelwood did a recent post on moving source code between TFS servers using  git tf. He mentioned that you could use the --deep option to get the whole changeset check-in history.

Being fairly new to using Git, in anything other than the simplest scenarios, it took me a while to get the commands right. This is what I used in the end (using the Brian Keller VM for sample data) …

C:tmpgit> git tf clone http://vsalm:8080/tfs/fabrikamfibercollection $/fabrikamfiber/Main oldserver --deep

Connecting to TFS...

Cloning $/fabrikamfiber/Main into C:Tmpgitoldserver: 100%, done.

Cloned 5 changesets. Cloned last changeset 24 as 8b00d7d

C:tmpgit> git init newserver

Initialized empty Git repository in C:/tmp/git/newserver/.git/

C:tmpgit> cd newserver

C:tmpgitnewserver [master]> git pull ..oldserver --depth=100000000

remote: Counting objects: 372, done.

remote: Compressing objects: 100% (350/350), done.

96% (358/372), 2.09 MiB | 4.14 MiB/s

Receiving objects: 100% (372/372), 2.19 MiB | 4.14 MiB/s, done.

Resolving deltas: 100% (110/110), done.

From ..oldserver

* branch HEAD -> FETCH_HEAD

C:tmpgitnewserver [master]> git tf configure http://vsalm:8080/tfs/fabrikamfibercollection $/fabrikamfiber/NewLocation

Configuring repository

C:tmpgitnewserver [master]> git tf checkin --deep --autosquash

Connecting to TFS...

Checking in to $/fabrikamfiber/NewLocation: 100%, done.

Checked in 5 changesets, HEAD is changeset 30

The key was I had missed the –autosquash option on the final checkin.

Once this was run I could see my checking history, the process is quick and once you have the right command line straight forward. However, just like TFS Integration Platform time is compressed, and unlike TFS Integration Platform you also lose the ownership of the original edits.

image

This all said, another useful tool in the migration arsenal.