简体   繁体   English

忽略本地git配置文件

[英]Ignoring Local git Config file

I am on Windows and have my diff and merge tools set in my global git configuration file. 我在Windows上,在我的全局git配置文件中设置了差异和合并工具。 Most of my project are in Visual Studio. 我的大部分项目都在Visual Studio中。 Some of the projects, I work with have a local config files in .git directory. 我使用的某些项目在.git目录中具有本地配置文件。 I think this is created when visual studio creates a repo. 我认为这是在Visual Studio创建存储库时创建的。 The issue is VS overrides my diff tools and merge tools with vsdiffmerge.exe. 问题是VS会覆盖我的差异工具,并使用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. 有没有一种方法可以告诉git优先于全局配置而不是本地配置。 I always use git on command line and expect beyond compare to open when I type "git difftool". 我总是在命令行上使用git,并且期望当我键入“ git difftool”时无法打开。 It is fine while doing a diff in VS to open vsdiffmerge. 在VS中进行比较以打开vsdiffmerge时很好。

The global Git configuration file on Windows for the logged-on user is located in the folder C:\\users\\<username>\\ , named .gitconfig . Windows上已登录用户的全局Git配置文件位于文件夹C:\\users\\<username>\\ ,名为.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 ). 您需要做的就是确保全局Git配置文件包含默认情况下要使用的difftool,并确保未在本地Git配置文件中列出该文件(该文件位于解决方案文件夹的.git文件夹下,位于文件名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. 您本地的Git config文件通常有两个[difftool]条目:一个用于指定是否提示您使用哪个difftool,另一个用于配置特定的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! ). 只需将本地Git配置文件中的条目复制到剪贴板,然后将其删除( 首先备份您的配置文件! )。 After that, open the global Git file and paste those entries there (or modify any existing [difftool] entries, as needed). 之后,打开全局Git文件并将这些条目粘贴到那里(或根据需要修改任何现有的[difftool]条目)。

At that point, your command-line Git difftool command will invoke the globally configured difftool rather than the locally defined one. 此时,您的命令行Git difftool命令将调用全局配置的difftool而不是本地定义的difftool。

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

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