I don't understand what all of these gitconfig files are for. On my machine, I have 3 gitconfig files.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team
Explorer\Git\etc\gitconfigC:\Program Files\Git\mingw64\etc\gitconfig
C:\Users\Jeff Dev\.gitconfig
(plus one for VS2022)
Some start with a period and some don't. Can someone please tell me the purpose of each of the files, and whether they should begin with a period or not, or direct me to another resource that will answer my question? Thank you!
I am trying to use WinMerge in Visual Studio 2019 with Git source control plug-in.
CodePudding user response:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\etc\gitconfig
The path showed that, thisgitconfig
is for the Visual Studio plugin calledTeam Explorer
.C:\Program Files\Git\mingw64\etc\gitconfig
is the system-wide (that is, user independent)gitconfig
C:\Users\Jeff Dev.gitconfig
... Do you meanC:\Users\Jeff Dev\.gitconfig
? This is the usergitconfig
.
Here "user" means the "account" in your computer.
And, for my experience, the read and override sequence is System -> User -> Application -> Repository. Then, 2 (system) will be read first, then override / appended by 3 (user), then 1 (application), maybe.
CodePudding user response:
There are three types of Git config files: system, global, and local.
A system config file contains settings for all users on the system. This is designed for setting configuration which affects the behavior of the Git installation. An example of when this is useful is when the system package manager installs Git LFS and needs to set the configuration to activate it. If the path contains etc/gitconfig
or etc\gitconfig
, then this is usually a system file.
A global configuration file is specific to a user and applies to all actions by that user (assuming HOME
is set properly). This is often used for aliases and other per-user configuration for all repositories. It is either located in $HOME/.gitconfig
or $XDG_CONFIG_HOME/git/config
. This would be the kind that starts with a dot, typically.
A local configuration file is stored in the .git
directory in each repository. This is going to be in .git/config
, and is used to specify remotes, values Git has detected about the file system (such as core.ignorecase
), and other per-repository changes.
The order of precedence is system, then global, then local. Later files override earlier ones.
In your case, 2 is the regular system config file, and 1 is likely a custom system config file used by the plugin. 3 is the global (per-user) config. I would not recommend removing 1 or 2, and in most cases, you will also want the global configuration file to at least set user.name
(your personal name) and user.email
(your email). So you probably can just leave them as they are unless something's broken.