简体   繁体   中英

Ignoring Local git Config file

I am on Windows and have my diff and merge tools set in my global git configuration file. Most of my project are in Visual Studio. Some of the projects, I work with have a local config files in .git directory. I think this is created when visual studio creates a repo. The issue is VS overrides my diff tools and merge tools with vsdiffmerge.exe. In my global settings it is set to as beyond compare. Is there a way I can tell git to give precedence to my global config instead of local config. I always use git on command line and expect beyond compare to open when I type "git difftool". It is fine while doing a diff in VS to open vsdiffmerge.

The global Git configuration file on Windows for the logged-on user is located in the folder C:\\users\\<username>\\ , named .gitconfig . All you need to do is to ensure that the global Git config file contains the difftool you want to use by default--and ensure that it's NOT listed in the local Git config file (which is located in your solution folder's .git folder under the file name config ).

Your local Git config file typically has two [difftool] entries: one to specify whether to prompt you for which difftool to use and the other to configure a particular difftool. It might look something like this:

[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

Just copy to the clipboard those entries from the local Git config file then delete them ( first back up your config file! ). After that, open the global Git file and paste those entries there (or modify any existing [difftool] entries, as needed).

At that point, your command-line Git difftool command will invoke the globally configured difftool rather than the locally defined one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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