In my day job I recently moved full-time into the land of Microsoft’s Team Foundation Server to manage source control. While it hasn’t been a smooth transition from Subversion, and an even rougher one from git, Matt Burke’s amazing git-tfs tool has come in super handy. In fact, thanks to recent pull requests by Jimmy Bogard, it even supports gated checkins against Visual Studio 2010.

One feature that is still on the wish list for git-tfs is support for translating TFS branches directly into git branches. I’d love to find the time to contribute that patch, but in the meantime I manage my TFS branches by having one distinct local git repo mapped to each TFS branch that I want to track.

The power of git allows me to connect these git branches locally, under the covers and unknown to TFS, by locally adding git remotes that point from one to the other. With those remotes in place locally I can pull changes from one local repo to the other, effectively rebasing changesets from one TFS branch to another by way of git.

When checking out a new TFS branch into a new local git repo, I have to remember the URL to the TFS server and the TFS working path to that branch as arguments into the git-tfs clone or git-tfs quick-clone commands, and for some reason I can never remember them.

For git remotes, the ‘git remote –v’ command does a great job of showing you the urls that existing remotes map to but that list never shows the tfs urls for branches checked out via git-tfs. Also, running ‘git tfs remote’ does nothing, so I went digging into the .git folder.

Turns out that git-tfs stashes that info in the [local repo root]/.git/config file

It contains a section that looks like this:

[tfs-remote "default"]
        url = [url to tfs server]
        repository = [$/path/to/source/repository]
        fetch = refs/remotes/default/master

where default is effectively the remote name.

If you have to work with TFS but prefer git for source control check out git-tfs.

You'll never look back.