Brian Harry announced the availability of
git-tf last Monday, a new tool from Microsoft that
allows you to create a local git repository from a path in Team Foundation
Server, then check the changes in your repository back in to TFS. This
tool is another piece in our cross-platform support, aimed at users of IDEs
that don't have built-in TFS integration.
We hope that Xcode users will find this particularly useful, as Xcode sadly lacks a plug-in model that would allow us to build TFS support natively. Xcode does have git support, however, so once you've created your git repository with git-tf, you can use Xcode's source code integration directly.
This means that if you're writing mobile applications, you can now use Team Foundation Server as your ALM solution for the entire development team. Imagine you have your shared business logic in C, you have a Windows Phone 8 version being developed in Visual Studio, an Android version being developed in Eclipse and an iOS version being developed in Xcode. Now all your developers can take advantage of TFS Version Control - your Visual Studio users with Team Explorer, your Eclipse users with the TFS Plug-in for Eclipse and your Xcode users with git-tf.
I'm too hopelessly old-school to be hip to the new mobile apps, so I'm going to show how I work on a cross-platform command-line application that plays blackjack. I've got my source in TFS, with an Xcode project side-by-side with my Visual Studio solution:
Once I have Xcode and git-tf installed on my Mac, I can download this project easily:
ethomson@mbp:~/Demo% git tf clone --deep http://tfs2012:8080/tfs/DefaultCollection $/DefaultAgile/blackjack Username: ethomson Password: Connecting to TFS... Cloning $/DefaultAgile/blackjack into /Users/ethomson/Demo/blackjack: 100%, done. Cloned 14 changesets. Cloned last changeset 19 as fb65c36
Now I have a git repository that represents my TFS changesets, with full
history. (That was the
--deep option, without that I would have a single git commit
that represents my latest TFS changeset. This is quicker to compute
and useful if you don't need full history.) You can see that my
history in Visual Studio:
is the same as the history in my local git repository:
ethomson@mbp:~/Demo/blackjack% git log commit f33b75c0190d76c417fd5d724236a9c3f731b185 Author: tfsuser <tfs2012\tfsuser> Date: Tue Aug 14 15:20:20 2012 -0500 This is a commit from Xcode commit a88b3887f1998fac74beb8ee32b4d91e06d8e625 Author: ethomson <tfs2012\ethomson> Date: Tue Aug 14 15:16:16 2012 -0500 This is a change from Visual Studio. ...etc...
When I open up this project in Xcode, you'll notice that when I start making changes to files, they're automatically added to my git index, as denoted by the small M next to the filename in Project Navigator. Below, I've made some changes to my project's assertion logic, changing Assert.cpp and Assert.h.
When Xcode's source control integration, I can commit these changes to my local git repository from right within my IDE. When committing, it will show a handy diff viewer for each file in my commit.
You can see the two commits I've made in my Xcode project in my git log.
ethomson@mbp:~/Demo/blackjack% git log commit 6f9bbafa5482c77de5b97b2548320b78de6b82fe Author: Edward Thomson <firstname.lastname@example.org> Date: Thu Aug 16 15:58:43 2012 -0500 Fixed some typos in the comments. commit 8dd92848b4ea0f6549d6f88d28e47c3e1201cd7c Author: Edward Thomson <email@example.com> Date: Thu Aug 16 15:55:01 2012 -0500 A couple of minor changes in Xcode ...etc...
Once I'm done making changes locally and I want to integrate with the
rest of the team, I can check them in to my TFS server using git-tf checkin.
Just like when I cloned my project, I can use the
--deep option to preserve history.
ethomson@mbp:~/Demo/blackjack% git tf checkin --deep
Connecting to TFS...
Checking in to $/DefaultAgile/blackjack: 100%, done.
Checked in 2 changesets, HEAD is changeset 21
Back in Visual Studio, you can see both of these changesets in my TFS history.
And, of course, since I'm doing Continuous Integration builds for this project, as soon as I checkin from git-tf, TFS queues up a build for me. In this case, I get two - one for each changeset, since I did a deep checkin from my two git commits.
So you can see that now I can easily use Xcode to take advantage of the ALM functionality of Team Foundation Server, providing every developer on a team with intuitive access to TFS Version Control.
git-tf is available now on CodePlex, Microsoft's Project Hosting for Open Source Software and we're making git-tf available open source under the MIT license. We think this is a very useful tool right now, and we're looking forward to making it even better.