Migrating source code with history to TFS 2012 with Git-Tf

Its hard to migrate source code even from one Visual Studio 2012 Team Foundation Server to another, especially when you also want to have your history. We have been forced in the past to use some hokie migration tools that only really partially work.

  • Update Anthony Borton gave me a hard time for not being able to get this working. However I had no problem with second set of code below.

With Git-Tf we can Clone a Team Foundation Server repository and with plane old Git we can do a Pull from one to the other and then push up to our target repository.

Figure: Running Git from the Command Line

The first thing we need to do in install Git-Tf and its dependencies. This will add the Git Bash command line and the TFS integration required to connect everything up. This is really me first time using Git as I have just not had time to play with it, but it looks solid so far.

Figure: Install with the cint Git-Tf command line call

When you clone a Team Foundation Server repository you can either get the tip or you can go deep. If you add the –deep  parameter on end you will effectively clone the history as well. For this particular task I only need the tip and I am really only need to go one way. You can however push source code back and fourth at will between the two servers or any other environment. A browse of the internet will also show you other source control systems that you can clone to Git. If you can clone you can pull and if you can pull you can checkin…

Figure: Git commands to move from TFS to TFS

Figure: Git commands to move from TFVC to TFS Git

The result of this is a move from my Team Foundation Service cloud account to my local test Team Foundation Server virtual machine.

If you are trying to move your source code from anything to Team Foundation Server this may be a good option. Its robust and will bring history across. I have not tested this at load but it should support reasonable sized repositories, large however will need some testing…

  • BTW – if you need to work with the command line for GIT and prefer Powershell to DOS let alone bash – check out Posh-Git https://github.com/dahlbyk/posh-git

  • Pingback: העברת קוד מפרויקט אחד לאחר ב – TFS בעזרת git - Eran Ruso()

  • Is there a way to take the workitem connections as well? I know there’s a few variants of Git-TF and some of them have workitem support…

    • Not this way. If you want work items as well then you need to use the TFS Integration Platform 😉

      • No go. We tried that and it fell over with an out of memory exception. It’s a 32-bit app, and there’s plenty of memory on the box, so I’m thinking it’s trying to store all data in memory, and hitting its memory limit because of the size of our repository.

        I was hoping that one of the Git-TF(S) implementations that support work items would be able to sync them over.

        Do you know what the issue is? Is it that it just stores the work item id or something?


        • I think… but have not tested… that if you write something to rip through all of your TFS code and add the Work Item ID to the comment in the right format (which I could not find right now) then when you move it across the comment goes with… now that is worth a test…

          • Interesting… It’s something I’ll have to try on our test environments (might not get it done today and I’m off next week so I’ll bookmark this for when I get back).


          • Philippe

            With git-tfs, we get the workitem ID when we fetch a changeset from TFS and put it in a note
            With some script, it should be possible to do it I think

            And with git-tfs, we support branches so we could migrate a repository that has branches (I even hope to finish merge support soon). Perhaps, it’s because TFS is such a bad tool that noone create branches and so no tutorial about migrate repository from TFSVC to Git talk about branches

          • John Ludlow

            I wouldn’t say that no-one creates branches – we use branches extensively.

            However, it does also depend on which version of TFS and Team Explorer you’re using (the latter usually determined by which version of Visual Studio) as to whether it’s a bad tool.

            Merging using the Visual Studio 2008 or 2010 Team Explorer is a pain I’m all too familiar with. Doing the same thing from Visual Studio 2012 and later, with properly created branches, is actually quite nice (though maybe not as fast as git).

          • Philippe

            > BTW, thanks for creating git tf – it’s an impressive tool
            I’m not the creator of git-tfS, just the 2nd bigger contributor 😉

            And the next release should be able to support branching and merging (a lot easier than with TFS 😉 )

        • Philippe

          There is now (just merge in the trunk and should wait the next release) a way to export workitems with git-tfs : https://github.com/git-tfs/git-tfs/pull/445
          You should be able to export and import back without problems!

  • Pingback: Using git tf to migrate code between TFS servers retaining history()

  • Pingback: Using git tf to migrate code between TFS servers retaining history - Richard Fennell()

  • Pingback: Migrating source from Perforce to Git on VSO - naked ALM - Experts in ALM, TFS & lean-agile with Scrum()


    Hopefully this thread is still checked..when I use the tag –deep, it says “error: unknown option ‘deep’

    • What is the full command you are typing to get that error? An example would be “git tf pull –deep”

      • BANNER

        was doing it like you have it above git pull tfplugable-tfvc-branch master –deep

        Currently in the process of trying it with the –deep at the end of step one instead. Was told that might be the correct way to do it.

  • Patrick Beverloo

    Please help me with the following error I am getting “Unable to find a required JAR: C:ProgramDatachocolateylibGit-TFToolsgit-tf-*.jar does not exist”

    • Bodya Bilas

      Hi, did you figure out with this problem?

    • Antti Kuntsi

      If you use a newish msys git client, check if your “uname -a” on the git bash reports MINGW32_NT or MINGW64_NT. If the latter, add a MINGW64_NT case into the git-tf script in the Tools -directory to use mingw32 as platform. You may also have to switch some forward and backward slashes around in the git-tf.cmd script that actually gets executed.