39

Does anyone know if there is a way to check if code from production hotfix branch is not newer than mainstream branch via diff tool of some sort? (hotfix1 vs thrunk)

\src
    \thrunk
    \releases
        \hotfix1

I'm using vs2010 with TFS, but the branches have a lot of files, and all I came up with was comparing one file at a time, by re-specifying the target path of one of them.

Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
Coder
  • 3,695
  • 7
  • 27
  • 42
  • 3
    You could cheat, download both branches locally, and use a diff tool (such as WinMerge or BeyondCompare) to recursively diff the directories. – Merlyn Morgan-Graham Jun 09 '11 at 08:38
  • 1
    I have found WinMerge to be great for this. I was hoping MS would add this ability to their web interface ( http://msdn.microsoft.com/en-us/library/bb822314(v=vs.90).aspx ) but it looks like they have not. – Abacus Aug 07 '13 at 14:11

7 Answers7

161

You can do this from right within Visual Studio - if you open Team Explorer and go to Source Control, you can compare folders recursively (even ones you don't have in your workspace.) Simply navigate to one of the branches, right click and select Compare and enter the other branch as the target.

Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
  • You can also find this in File/Source Control/Compare, you can compare any arbitrary files. Also, right click on the file in Source Control Explorer and chose Compare. – Mihai Drebot Feb 15 '16 at 13:03
  • 9
    Does this work in Visual Studio 2015? I can't find it. – Jess Apr 13 '16 at 16:19
  • Note that this comparison is based on the mergehistory. In case you edited the mergeresult (for example by using mergetool), this will NOT show up using `Compare`. – Menno Jan 18 '17 at 13:31
16

In Visual Studio, in the menu bar select:

  1. View >> Other Windows >> Source Control Explorer
  2. Right click the item (folder, branch, file etc.) >> Compare...
  3. Enter the item to compare to in the Target Path as shown below

NOTE: Notice all the different options you have on this screen.

enter image description here

CodingYoshi
  • 25,467
  • 4
  • 62
  • 64
  • This worked for me on VS2019 too. And with the Google search's snapshot of it, so voted up without reading further. – Ozair Kafray Apr 01 '21 at 10:49
  • Is there a way to execute this on the command line with the help of tf by using the option Target Version by Changeset? I know of the ``tf diff`` and the ``tf folderdiff`` command but both of them do not work with the target version filter (or I just missed it) – Lori Oct 22 '21 at 09:18
5

Using the "Compare" function as mentioned previously is great, but having good filters makes it way more useful. Otherwise you can get overloaded with huge amounts of info.

Here are the filters I am currently using which work very well for me:

!debug\;!obj\;!bin\;!temp\;!*ReSharper*\;*.sln;*.*proj;*.config;*.cs;*.vb;*.bmp;*.GIF;*.JPG;*.png;*.ico;*.ini;*.resx;

The first few items eliminate some folders you probably want to exclude (debug, obj, bin, temp, Resharper stuff if you are using it - and it is highly recommended that you do!). The rest are the files that I find useful to include in the search. If there are other file types you want to see, just add them to the end of the list.

Mick Bruno
  • 1,373
  • 15
  • 13
5

Using the command line tool tf.exe you can compare two revisions of arbitrary files, but both have to be in your workspace.

See online help on tf diff for details (and here for specifying versions).

NB. In VS use Tools | Options | Source Control | Visual Studio Team Foundation Server | Configure User Tools to define what diff/merge application to use (a web search will find the right command line to use). Entering .* for the file type will be used for everything without a more specific tool set.

Richard
  • 106,783
  • 21
  • 203
  • 265
2

You can merge one branch into the other without committing. Then you can see all the changes in visual studio. When you're done you just have to reset all the changes (if you don't want to merge).

Fl4v
  • 1,024
  • 11
  • 19
0

actually you dont have to be in the same workspace to do compares from VS - or even both in TFS. 1 or both could be in the file system ("Local Path..." in "Compare" dlg) or in TFS ("Server Path..."). THe "Filter" section is very powerful as well, to be able to expand/restrict the comparison objects by file type.

galaxis
  • 925
  • 8
  • 10
0

You can do it easily from Visual Studio, but if you are like me and don't want to mess you local branch, you can also do it from the VSTS Website

  • go to the pull request
  • select the Files tab
  • select the file you want to compare (you will see ...) that will open a menu
  • View History
  • Find the file you want to compare
  • Select Tab Compare
  • You will see the commit number on top that you can change to compare the versions of your file

it is not as difficult as it sounds, :)

Sebastian Castaldi
  • 8,580
  • 3
  • 32
  • 24