TFS Command Line Katas: Part 1 – Basic TF.exe Concepts

The TFS command line client, tf.exe, is a powerful tool that may be somewhat intimidating or elusive to learn if you primarily work through within Visual Studio.  In fact, you can do many things in tf.exe that are not available through the Visual Studio source control interface.  tf.exe has been around since the earliest days of Team Foundation Server 2005, yet many developers don’t even know it exists.

To help you become more familiar with it, I’ll be blogging a short series of katas – small exercises you can repeat over and over until you’ve mastered the interface.  Today, I present the first kata – basic tf.exe commands.

Getting Started:

In order to use these katas, you’ll need to first do the following:

  1. Open the Visual Studio command prompt: Start –> All Programs –> Microsoft Visual Studio 2010–> Visual Studio Tools –> Visual Studio Command Prompt.  This will ensure that tf.exe is in your %PATH% environment variable so you don’t have to type the full path to it each time you use it.
  2. cd into a folder where you have an existing TFS workspace mapped. This is how tf.exe will know what workspace and server to work against.


TFS Command Line Kata #1 – TF.EXE Basics

My first kata introduces some of the most used commands in the command line client.  In particular, all of these can work without any additional parameters other than the command name.  I’ll address more complex commands in future posts.

  1. tf /? – list all available tf.exe commands
  2. tf workspace – view details about the current workspace
  3. tf workfold – view a list of server folders and the local folders they’re mapped to for the current workspace
  4. tf workspaces – view a list of all workspaces on the current machine
  5. tf dir – view a listing of files & folders in the source repository folder mapped to the current local folder
  6. tf status – view pending changes in the current workspace

That’s enough for now.  Remember, katas are short and simple, easy to memorize and repeat daily.  Work on these for a few days while I prepare the next post in the series.  If you have questions about the command line interface to TFS, please post comments.

Comments (4)

  1. Eyal says:

    I'm using the command line interface a lot lately to automate repeating tasks and it's very easy to use once you get the basics.

    One thing I was not able to find is whether it allows to set the "current" comment via the command line. I have a script that merges changesets from one branch to another and I want to use the same comment i've used in the original changeset after the merge is complete (I'm not checking-in via the command line – just doing the merge)

  2. Jason Barile says:

    I don't think there is an option for this automatically from the tf.exe cmd line.  You could probably do this with the TFS Powershell Power Tools or the PSTFS project on codeplex (

  3. Br.Bill says:

    The command line never knows where you are or what your context is. There's no reason for this but it is true anyway. Anything you can do from another SCM tool's command line in one line requires several commands in TFS. It's horrible.

  4. Jason Barile says:

    Br. Bill: Can you elaborate?  If your current working directory is a mapped folder then tf.exe will work within the context of that workspace.  What are you trying to do that requires several commands with tf.exe that only takes one with other source control systems?

Skip to main content