Diff between commits in Visual Studio 2015 using git

ε祈祈猫儿з 提交于 2019-12-06 17:03:00

问题


Using Visual Studio 2015 Update 2 and git as source control, how do you diff between 2 commits on a branch? Note that I am not talking about diff on the granular file level (ie. view history of file and comparing), but rather for entire commits.

I would expect to be able to compare when looking at the history of a branch, but the option does not exist. Here's the right click menu I see when I right click on a commit when viewing the history of a branch:

Where's the compare??


回答1:


While not possible in Visual Studio 2015, this functionality will be included in Visual Studio 2017.

In Visual Studio 2017 it will be possible to get the changes between two different commits. This functionality can be accessed via selecting two commits on the history page and choosing the "Compare Commits..." command:

This functionality is present in the preview releases of Visual Studio 2017, so you can try it out and see if it is what you are looking for.




回答2:


Don't know about VS 2015 update 2. But, in update 3, you can...

1) Right click a commit from history and select View Commit Details from the context menu

2) Right click the file you want to look at and select Compare with Previous from the context menu.

3) View diff window...

(Don't think you can get diff with two non-consecutive commits.)




回答3:


In Visual Studio 2015, to get a diff with two non-consecutive commits:

  • Make sure the two commits are on different branches
  • Checkout the earlier commit, then right-click on it in Team Explorer and choose "Merge From"
  • Select the later commit to merge from. Make sure the "Commit changes after merging" checkbox is NOT checked then click on Merge
  • All changes will be shown between the two commits in the "Changes" view of Team Explorer. You can Abort the Merge after you're done with the diff if you wish


来源:https://stackoverflow.com/questions/37818902/diff-between-commits-in-visual-studio-2015-using-git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!