Visual differences of changesets via command-line

Scenario : as a developer you want to manually view all the differences between the two last changesets without having to spend your time reviewing file after file in the UI differences window.

Go the command prompt and use the tf diff[erence] command:

tf diff source /version:C22~C23 /recursive /format:unified > C:\Temp\diff.txt

  • source is the name of the folder I want to recursively [/recursive] look up all differences
  • /version:C22~C23 means that I want to find only the differences between changeset 22 and changeset 23
  • /format:unified sets the output type to the Unified format derived from the UNIX based diff –u output format
  • > C:\Temp\diff.txt sends the output to the diff.txt textfile

When finished open the diff.txt file in an editor that supports a difference scheme. In the example below I used Notepad2 to load the output file in the diff scheme.

The information written into the textfile is only the specific region in each textfile that’s different from the previous changeset. It’s a nice way to visually review only the portions of a set of files that were changed. It will save you a lot of time if you otherwise would want to review file by file via the GUI.

4 Responses to Visual differences of changesets via command-line

  1. Marc says:

    This is a good step in the right direction for what I need to do.

    I am having a problem with the “source” aspect of the command. Could you post an example of the syntax? Is it a physical path or the TFS server path?

    Thank you.

  2. Hi Marc,

    “source” is the relative path to the folder you want to run the command (recursively or not) …

    Hope this helps!


  3. Marc says:

    I found that it works best to run the command in the directory that is the root of your source code tree.

    I had to perform separate diffs for 60+ change sets. I automated this in batch file and works perfectly. Thank you so much for the helpful article.

  4. Vanavara says:

    Thank you very much! Very powerfull answer!
    You’re not imagine how much of my time you have saved.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: