101

I am using Visual Studio 2012 with TFS. Whenever I want to compare my checked out files, I have two options to choose from:

  1. Compare with workspace version
  2. Compare with latest version

screenshot

What is the difference ?

Bilal Fazlani
  • 6,727
  • 9
  • 44
  • 90

4 Answers4

89

Compare with Latest version seems clear. It compares files against the latest version in TFS. So you'll get all the differences between the very latest version checked into source control and whichever folder you're comparing against.

Compare with Workspace version might be confusing, but is actually pretty simple. TFS keeps track of the version of the file which you've retrieved into your workspace. This is usually the latest version, or pretty close to that, but that doesn't have to be the case.

When using the Get Specific Version option you can retrieve any version of a file to your local workspace. You can even retrieve files from different versions into your workspace. When you select this option, a comparison will be done against the version that is currently in your workspace.

Compare screen

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • "When you select this option, a comparison will be done against the version that is currently in your workspace." comparison with what ? – Bilal Fazlani Nov 27 '13 at 04:52
  • With the version on disk by default. Or Whatever version you select as target path. In the end you are ultimately responsible to pick the source and the target version for a comparison. – jessehouwing Nov 27 '13 at 07:10
  • to be specific .... From team explorer, if you right click on a file.. you dont get this dialog box.. u just see those two options. There, if I select `compare with workspace version`, what will be be compared with what ? – Bilal Fazlani Nov 27 '13 at 07:22
  • 2
    With the changeset version you last downloaded to the selected workspace with whatever is currently on disk. – jessehouwing Nov 27 '13 at 08:02
  • Is this distinction possible if you choose a "Server Workspace"? http://blogs.msdn.com/b/phkelley/archive/2013/05/29/server-workspaces-vs-local-workspaces.aspx – Nate Anderson Oct 07 '14 at 00:09
  • @TheRedPea, yes, this works regardless of workspace type. I'm not sure whether Visual Studio will use the local workspace baseline if you're using a local workspace, but in the worst case it will always request the common baseline from the server. – jessehouwing Oct 07 '14 at 12:17
  • 2
    To add further clarity, getting a workspace version can be different from latest or the same thing as latest. It is entirely dependant on what you pulled down from your repository – Callat Jun 26 '17 at 12:04
  • 3
    Example: You're on a team and on 3/5 you obtain a file. You modify it but don't check in. On 5/5 you compare with last version and you see that you find more differences than expected: That's because someone else made more changes to the same file. But if you compare with Workspace version, you'll get only the differences between your local changes and how the source file was WHEN YOU RETRIEVED IT initially. Very useful to check what ONLY you had changed... – Roger Mar 05 '19 at 17:23
82
  • Comparing with workspace version actually compares the edited file with the version of file at the time you checked out (compares exclusively your changes).

  • Comparing with latest version compares the edited file with latest version of file present at your code repository i.e. it might include changes made by your colleagues.

http://codereferences.blogspot.ca/2012/03/tfs-compare-with-workspace-version.html

Aaroninus
  • 1,062
  • 2
  • 17
  • 35
serhio
  • 28,010
  • 62
  • 221
  • 374
  • 1
    serhio, you and @jessehouwing are stating conflicting behaviors for the Workspace Version compare type. Sounds like he is stating that the latest version of the file will be used if the workspace itself is configured to use the latest version. However what you say implies that the source file may not necessarily be the latest version, but the version of the file during it's checkout? – samus Oct 11 '16 at 13:38
  • 2
    This is the best simplest explanation. Workspace does not retrieve latest version from server automatically. It keeps the file you got latest. So let's say you get latest, edit the file. Meanwhile, your co-developer checked-in, after you got latest. Your Workspace doesn't know about your co-developer checked-in changes. At this point, the Compare with Workspace & Compare with Latest Version will differ. – Nathan Nov 07 '16 at 17:22
  • @serhioI didn't say that. It's the version from the moment of checkout. Generally that's latest at time of checkout. If time goes by Workspace Version may turn into latest-18 or something. But you can also explicitly check out a changeset version. Even f latest is 234, if you check our the workspace at version 123, then `123` will be your workspace version. So Workspace version can mean many things, especially when you start to use it to build older versions, cherry-pick changes or do partial mergefs, this can become very important and very handy. – jessehouwing Aug 19 '21 at 17:47
6

@serhio's 3/28/14 answer is an excellent narrative answer. However, I'm sure many (including myself) needs that backed-up with an example, and here it is:

  1. For everyone, "Lastest Version" = Changeset # 1.
  2. You "Get Latest".
  3. For you, "Workspace Version" = Changeset # 1.
  4. You make changes.
  5. Developer B "Get Latest".
  6. For Developer B, "Workspace Version" also = Changeset # 1.
  7. Developer B makes changes.
  8. Developer B "Check-in".
  9. For everyone, "Lastest Version" = Changeset # 2.
  10. For Developer B, "Workspace Version" = Changeset # 2.
  11. For you, "Workspace Version" still = Changeset # 1.
  12. You "Get Latest", "Merge Conflicts" (if necessary) and "Check-in".
  13. For everyone, "Lastest Version" = Changeset # 3.
  14. For you, "Workspace Version" = Changeset # 3.
  15. For Developer B, "Workspace Version" still = Changeset # 2.
Tom
  • 870
  • 11
  • 13
2

To restate the Answer:

The local file is always the one you are working on.

The server file can either be:

  1. The latest version including all other check-ins. (You see your changes, as well as other peoples changes.)

  2. The Version as it was when you checked it out (You see only your changes, even if other people have checked in since).

If no other people check in files since your checkout, then the both of the above produce exactly the same result.

So if you want to compare what you have done against what it was when you started, select Workspace Version

If you want to compare what you have done against what other people have done, select Latest Version

Greg Gum
  • 33,478
  • 39
  • 162
  • 233