Coder
Coder

Reputation: 3715

Is there a way to compare two branches for differences/file versions in VS2010?

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.

Upvotes: 39

Views: 41260

Answers (7)

CodingYoshi
CodingYoshi

Reputation: 27009

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

Upvotes: 16

Sebastian Castaldi
Sebastian Castaldi

Reputation: 9004

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, :)

Upvotes: 0

Fl4v
Fl4v

Reputation: 1062

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).

Upvotes: 2

Mick Bruno
Mick Bruno

Reputation: 1433

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.

Upvotes: 5

galaxis
galaxis

Reputation: 945

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.

Upvotes: 0

Edward Thomson
Edward Thomson

Reputation: 78673

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.

Upvotes: 161

Richard
Richard

Reputation: 108995

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.

Upvotes: 5

Related Questions