简体   繁体   English

在 VS2015 TFS Git 源代码管理中将当前文件与历史版本进行比较

[英]Compare current file to historical version in VS2015 TFS Git Source Control

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.这是 TFSVC 的最佳功能之一,我希望它在 VS2015 中支持 GIT 的深处。

Edit: since there is no official solution: I've created a User Voice item as suggested by @Patrick-MSFT编辑:因为没有官方解决方案:我按照@Patrick-MSFT 的建议创建了一个用户语音项目

Allow "Compare working copy to historical version" version in git -- VS Developer Community 在 git 中允许“将工作副本与历史版本进行比较”版本-- VS 开发者社区

This is not supported now.现在不支持此功能。

You can vote for this feature request here:您可以在此处投票支持此功能请求:

Allow "Compare working copy to historical version" version in git 允许在 git 中“将工作副本与历史版本进行比较”版本

In Vs, you can only compare your currently edited version with the unmodified status.在 Vs 中,您只能将当前编辑的版本与未修改的状态进行比较。

显示“与未修改的比较...”的解决方案资源管理器文件上下文菜单

Still no support in VS2019!在 VS2019 中仍然不支持! :( :(

Use Notepad++ and the Compare plugin.使用 Notepad++ 和 Compare 插件。 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...您还将获得 WITHIN 行的更改,这比 VS 支持的比较要好得多...

To perform a difference while in Visual Studio use a Command Window with Tools.DiffFiles :要在 Visual Studio 中执行差异,请使用带有 Tools.DiffFiles 的命令Tools.DiffFiles

  1. In View History , select the historical file and open context menu to select Open .查看历史记录中,select 历史文件并打开上下文菜单以 select打开
  2. Open a Command Window打开命令 Window
  3. In the Command window type Tools.DiffFiles , paste the two full paths, and hit Enter.命令 window 中键入Tools.DiffFiles ,粘贴两个完整路径,然后按 Enter。
  4. Example: Tools.DiffFiles c:\original.cs c:\historical.cs示例: Tools.DiffFiles c:\original.cs c:\historical.cs

Reminder: the full path can be copied from the open file's tab's context menu via Copy Full Path提醒:可以通过复制完整路径从打开文件选项卡的上下文菜单中复制完整路径

There is a workaround有一个解决方法

But read this comment first as it tells you the correct answer to the question: https://stackoverflow.com/a/34127749/563688但请先阅读此评论,因为它会告诉您问题的正确答案: https : //stackoverflow.com/a/34127749/563688

The workaround解决方法

  • Download Visual Studio Comparison Tools (it implements a Compare to Clipboard -feature)下载Visual Studio 比较工具(它实现了与剪贴板比较功能
  • 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右键单击并单击与剪贴板比较

将历史版本代码复制到当前版本(确保当前版本已经提交),然后使用“与未修改的比较”....

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除了对 UserVoice 投票(我已经完成),您还可以在 VS 2017 中使用这种方式: Git 和 Visual Studio 2017 第 13 部分:在 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.." Actions 和 View History,然后选择您需要比较的最后一个 Push 和历史提交,然后选择“Compare committs..”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM