Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Git config list (total) is not the same as system + global + local

Tags:

git

On Git 2.6.3 on Windows, why this command result:

git config --list

Is not the same as this others:

git config --list --system
git config --list --global
git config --list --local

The first one has a few more options listed than the sum of the others. I have redirected to files and kdiff compare and there are differences.

As requested this is the values there are in git config --list and not in the system/global/local grouped:

core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=C:/Program Files (x86)/Git/mingw32/ssl/certs/ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true

Where are that config quoted above (not in system/global/local) values saved?

like image 779
ferpega Avatar asked Dec 05 '15 22:12

ferpega


People also ask

When configuring git there are local and global settings How do they differ?

System vs Global vs Local Git config System Git config controls settings for all users and all repositories on your computer. Global Git config controls settings for the currently logged in user and all his repositories. Local Git config controls settings for a specific repository.

How do I change my git config list?

Show global git config settings But at runtime, only the value set locally is used. If you would like to delete or edit a Git config value manually with a text editor, you can find the Git config file locations through the Git config list command's –show-origin switch.

Is git config global?

The git config command is a convenience function that is used to set Git configuration values on a global or local project level. These configuration levels correspond to . gitconfig text files. Executing git config will modify a configuration text file.


Video Answer


2 Answers

TL;DR: C:\Users\All Users\Git\config.
See git-for-windows PR 470

On Windows, as there is no central /etc/ directory, there is yet another config file (located at %PROGRAMDATA%\Git\config), intended to contain settings for all Git-related software running on the machine.
Consequently, this config file takes an even lower precedence than the $(prefix)/etc/gitconfig file.

You can check that (with git 2.8+, March 2016), by typing

git config --list --show-origin

See "Where do the settings in my Git configuration come from?"


As mentioned in git config FILES, git is looking for values (or default values if not found) of configs in 3 places (outside the git repo itself)

$(prefix)/etc/gitconfig

System-wide configuration file.

$XDG_CONFIG_HOME/git/config

Second user-specific configuration file.
If $XDG_CONFIG_HOME is not set or empty, $HOME/.config/git/config will be used. Any single-valued variable set in this file will be overwritten by whatever is in ~/.gitconfig. It is a good idea not to create this file if you sometimes use older versions of Git, as support for this file was added fairly recently.

~/.gitconfig

User-specific configuration file. Also called "global" configuration file.

But a quick process monitor mentions a fourth place (again, outside a git repo itself)

programdata

In C:\ProgramData\Git, I see the extra values:

C:\ProgramData\Git>more config
[core]
        symlinks = false
        autocrlf = true
[color]
        diff = auto
        status = auto
        branch = auto
        interactive = true
[pack]
        packSizeLimit = 2g
[help]
        format = html
[http]
        sslCAInfo = C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
[sendemail]
        smtpserver = /bin/msmtp.exe

[diff "astextplain"]
        textconv = astextplain
[rebase]
        autosquash = true

As mentioned in "What is the significance of the ProgramData folder in Windows?", that folder is the one from All Users:

C:\Users\All Users\Git>dir
 Volume in drive C has no label.

 Directory of C:\Users\All Users\Git

23/10/2015  16:36    <DIR>          .
23/10/2015  16:36    <DIR>          ..
23/10/2015  16:36               350 config
like image 199
VonC Avatar answered Sep 22 '22 14:09

VonC


Git reads values from three different configuration files.

  1. System - Configuration values in this file are applied to all the users on the machine.
  2. Global - Configuration values in this file are applied to a single user. This file is located at '~/.gitconfig'. This file can be used to overwrite configuration value set by system configuration file.
  3. Local - Values in this file apply to a single repository. This file is located at '.git/config'. This file can be used to overwrite configuration values set by global and system configuration files.

For example, you configure your git install to use your email address

git config --global user.email [email protected]

Now you are working on a project. This specific project requires you to use different email address [email protected]. But all the other projects still use [email protected]. You can set email address for a specific repository using

git config --local user.email [email protected]

Git reads all three config files and combines configuration values from all the files to come up with the final set of configuration values. If git doesn't find values for required git configuration variables in the final set of configuration values, then it will use default internal values for the variables.

like image 45
Abhijit Amin Avatar answered Sep 26 '22 14:09

Abhijit Amin