git compare branch changes with VisualStudio

Sometimes you need to compare the differences between two branches. If you submit it to github, you can see it by default. But at this time, because there is no ide highlighting or other functions, it doesn't look good.

The default VisualStudio comparison file is much better to use than github's, so how to use VisualStudio for code comparison?

Try opening VS and compare the two files at will. I need to find a tool. This tool is placed in the TeamFoundation folder. I am VisualStudio 2017 here. So my path is C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\vsDiffMerge.exeto open my own folder to search and find this software.

Then open it from cmd and enter the following code

vsDiffMerge.exe 文件1 文件2

As you can see, the software is compared from VisualStudio

If you are using Powershell, you can enter cmd to enter the command line

It can be seen that the comparison file is very useful, then the default comparison branch used by git is git difftool dev releaseto compare two branches, but how to use vs to compare?

The method used actually requires only one file to be modified

Open the .git config and add the following code at the end of the file

[diff]
    tool = vsdiffmerge
[difftool]
      prompt = true
[difftool "vsdiffmerge"]
      cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\vsDiffMerge.exe\" \"$LOCAL\" \"$REMOTE\" //t
      keepbackup = false
      trustexistcode = true
[merge]
      tool = vsdiffmerge
[mergetool]
      prompt = true
[mergetool "vsdiffmerge"]
      cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\vsDiffMerge.exe\" \"$LOCAL\" \"$REMOTE\" //t //m
      keepbackup = false
      trustexistcode = true

The file path in it needs to be installed by yourself.

If you can't find the file, you can use the git command line in the repository to enter the following code

git config --global difftool.visualstudio.cmd "'C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/vsdiffmerge.exe' \$LOCAL \$REMOTE Source Target //ignorespace //t"

git config --global mergetool.visualstudio.cmd "'C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/vsdiffmerge.exe' \$LOCAL \$REMOTE \$BASE \$MERGED //ignorespace //m"  
git config --global mergetool.visualstudio.trustExitCode true

git config --global diff.tool visualstudio  
git config --global merge.tool visualstudio 

If you need to modify your own file, you can generally find it by searching.

Ignore compared folders

If there is a certain file in the git submission that is a resource, in the comparison, you need to look at these files constantly, and I feel like I want to unload git. But git is so powerful, is there a way to ignore changes in a certain folder? Yes, let me tell you how to ignore this folder.

For example, the file that needs to be ignored is the folder where the c:\code\dx\resourceproject is located c:\code\dx, and dx is my name, so the project is fake.

Use git to enter the following command to ignore the resource folder

git difftool relase dev -- . ':!resource'

This command needs to pay attention to, -- . ':!要忽略的文件夹'except Chinese, others need to be added

I built my own blog https://lindexi.gitee.io/ Welcome everyone to visit, there are many new blogs in it. I will only put it on csdn or blog garden after I see that the blog is mature, but it will not be updated once it is published

If you see anything you don’t understand on the blog, welcome to communicate. I have built a dotnet vocational and technical college. Welcome everyone to join.

Creative Commons License
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. You are welcome to reprint, use, and republish, but be sure to keep the article's signature Lin Dexi (including the link: http://blog.csdn.net/lindexi_gd ), and must not be used for commercial purposes. Works modified based on this article must be released with the same license. If you have any questions, please contact me .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325031207&siteId=291194637
Recommended