Compare current file to historical version in VS2015 TFS Git Source Control
Asked Answered
C

6

22

When I pull up the history of the file I can compare that version with another version listed in the history by selecting both and doing a "Compare", or I can compare a historical version and it's changes wrt to it's previous version by selecting "Compare to Previous".

However I cannot find a command that will let me compare a historical version in the history list to the currently edited version on disk. Does anyone know what this command is called so I can hook it into the context menu please?

This was one of the best features of TFSVC and I'm hoping it's somewhere deep in the bowels of the GIT support in VS2015.

Edit: since there is no official solution: I've created a User Voice item as suggested by @Patrick-MSFT

Allow "Compare working copy to historical version" version in git -- VS Developer Community

Calicle answered 6/12, 2015 at 22:34 Comment(1)
As UserVoice is now closed, I've re-entered this suggestion on the Developer Community site. developercommunity.visualstudio.com/idea/370956/…Octahedral
U
16

This is not supported now.

You can vote for this feature request here:

Allow "Compare working copy to historical version" version in git

In Vs, you can only compare your currently edited version with the unmodified status.

Solution Explorer File Context Menu Showing "Compare with Unmodified..."

Unclear answered 7/12, 2015 at 6:33 Comment(2)
As UserVoice is now closed, I've re-entered this suggestion on the Developer Community site. developercommunity.visualstudio.com/idea/370956/…Octahedral
Good to know it is not supported! Soluton is to use better software for file comparisons.Erfert
E
3

Still no support in VS2019! :(

Use Notepad++ and the Compare plugin. Open file versions of interest, select first version as set "first version to compare", then select second version and "compare". There you have the diff!

You will also get changes WITHIN rows, which is far better than compare supported by VS...

Erfert answered 19/5, 2021 at 8:50 Comment(1)
THanks for answering this. I'm hoping that have 5 years. This will be of help to someone.Calicle
B
0

To perform a difference in Visual Studio use a Command Window with Tools.DiffFiles:

  1. Open a Command Window via View > Other Windows > Command Window.
  2. In the Visual Studio's Command Window type Tools.DiffFiles.
  3. Copy the full path of the original file using the open file's tab's context menu via Copy Full Path, e.g. c:\original.cs
  4. Paste full path into the Command Window, e.g, Tools.DiffFiles c:\original.cs
  5. In Visual Studio's View History, select the historical file and open context menu to select Open, e.g., c:\historical.cs.
  6. Copy the full path of the historical file using the open file's tab's context menu via Copy Full Path, e.g. c:\historical.cs
  7. Paste full path into the Command Window, e.g, Tools.DiffFiles c:\original.cs c:\historical.cs
Boxhaul answered 22/9, 2022 at 10:32 Comment(2)
How do you get both files? The point is that I can always clone the repo at the old version commit and diff the files. The question was about diffing in the visual studio git explorer window. A feature that was available in other got tools.Calicle
The above workflow is all done in Visual Studio. The "trick" is to get the historical file path from the file opened from Visual Studio's git View History window.Boxhaul
S
-1

There is a workaround

But read this comment first as it tells you the correct answer to the question: https://mcmap.net/q/581226/-compare-current-file-to-historical-version-in-vs2015-tfs-git-source-control

The workaround

  • Download Visual Studio Comparison Tools (it implements a Compare to Clipboard-feature)
  • Open View History for the file to compare
  • Scroll down to the historical commit and Open
  • Copy historical code
  • Go back to current version of the file
  • Select all text
  • Right click and click Compare to Clipboard
Staciastacie answered 6/10, 2020 at 6:18 Comment(0)
C
-1

Copy historical version code to current version (make sure curent version is commited already), then use "compare with unmodified"....

Clew answered 14/1, 2021 at 15:28 Comment(0)
C
-3

Besides voting on UserVoice (I've done) you can use this way with VS 2017: Git and Visual Studio 2017 part 13 : Compare your items in VS

Go to Team Explorer | Changes | Actions and View History, then select the last Push and the historical commit that you need to compare and select "Compare committs.."

Catechin answered 1/7, 2018 at 11:14 Comment(2)
was helpful to me but is not what the author had askedHecklau
And if you don't want to commit, let alone push, before doing your comparison?Serriform

© 2022 - 2024 — McMap. All rights reserved.