简体   繁体   English

如何使用Visual Studio git集成查看合并提交中更改的文件

[英]How to see the files changed in a merge commit using Visual studio git integration

I'm using the visual studio git integration and trying to see which files were changed in a merge commit. 我正在使用visual studio git集成并尝试查看合并提交中哪些文件已更改。

Say I am looking at the history of my dev branch and I have merged from master into dev. 说我正在查看我的dev分支的历史,并且我已经从master合并到dev中。 If I look at the merge commit, it shows the files I have edited in dev; 如果我查看合并提交,它会显示我在dev中编辑的文件; what I want to see is the changes I have merged from master (in command-line terms I think what I'm looking for is "git show -m --first-parent"). 我想看到的是我从master合并的变化(在命令行术语中我认为我正在寻找的是“git show -m --first-parent”)。

Is there any way to achieve this with the visual studio integration? 有没有办法通过visual studio集成实现这一目标? failing that, are there any free tools that would list the changed files and then be able invoke my standard git difftool to see the individual changes. 如果没有,是否有任何免费工具可以列出已更改的文件,然后可以调用我的标准git difftool来查看各个更改。

Viewing the changes in a merge commit can be approached in several ways. 可以通过多种方式查看合并提交中的更改。

  • Diff with ALL parents – One common approach is to diff a merge commit with all of its parents. 与所有父对象的差异 - 一种常见的方法是与其所有父对象区分合并提交。 Any change that can be found in at least one parent is not a change in that merge commit, so merge commits will frequently show as empty unless there were conflicts that had to be resolved. 在至少一个父级中可以找到的任何更改都不是该合并提交中的更改,因此除非存在必须解决的冲突,否则合并提交将经常显示为空。

  • Diff with FIRST parent – Another common approach is to diff a merge commit only with its first parent. 使用FIRST父进行Diff - 另一种常见方法是仅使用其第一个父进行合并提交。 The idea is if merging topic->master, then master will be the first parent. 想法是如果合并topic-> master,那么master将是第一个parent。 Diffing against master will then show all changes that flowed in from the topic branch in this merge. 然后,与master进行区分将显示从此合并中的主题分支流入的所有更改。

  • Let the user pick – Allow diffing with all parents or choosing a specific parent. 让用户选择 - 允许与所有父母进行差异或选择特定父母。

To see this difference in merge commit display, here's an example using the diff-tree command. 要在合并提交显示中看到这种差异,这是使用diff-tree命令的示例。

  • "git diff-tree -m < merge_commit_id >" – This command will show the changes against individual parents. “git diff-tree -m <merge_commit_id>” - 此命令将显示针对个别父母的更改。 The merge commit will not appear to be empty. 合并提交似乎不是空的。

  • "git diff-tree -c < merge_commit_id >" – The -c option instructs Git to "list only files which were modified from all parents". “git diff-tree -c <merge_commit_id>” - -c选项指示Git“仅列出从所有父节点修改的文件”。 This command will show no changes in the merge commit unless a conflict resolution or other change was made directly in the merge commit. 除非在合并提交中直接进行冲突解决或其他更改,否则此命令将不会显示合并提交中的任何更改。

The current behavior in VS 2017's Commit Details view is to diff with all parents of a merge commit. VS 2017的“提交详细信息”视图中的当前行为是与合并提交的所有父项进行区分。 We have found through user feedback that this is the option that is least confusing to users since it is a consistent view regardless of the direction of the merge. 我们通过用户反馈发现,这是对用户最不容易混淆的选项,因为无论合并的方向如何,它都是一致的视图。 In a future update, hopefully the feature will be enhanced to also support selecting an individual parent against which to diff. 在未来的更新中,希望该功能将得到增强,还可以支持选择要对其进行区分的单个父级。

As a workaround, another option is to use VS 2017's Compare Commits feature. 作为解决方法,另一种选择是使用VS 2017的比较提交功能。

  1. View the history of your dev branch. 查看您的开发分支的历史记录。
  2. (optional) Click the toolbar button for "Show First Parent Only". (可选)单击“仅显示第一个父项”的工具栏按钮。
  3. Select the merge commit and the parent against which to diff. 选择合并提交和要与之对比的父级。 In first parent mode, this will be the next commit in the list. 在第一个父模式下,这将是列表中的下一个提交。
  4. Right click and choose Compare Commits. 右键单击并选择Compare Commits。

Hope this helps! 希望这可以帮助!

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

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