Es gibt 4 Orte, an denen Git nach einer Konfiguration sucht - wenn nicht per --file Option eine explizite Datei als Konfigurationsquelle festgelegt wurde. TL;DR
- System-spezifische Konfiguration -
git config --system -l
- User-spezifische Konfiguration I -
git config --global -l
- User-spezifische Konfiguration II -
git config --global -l
- Repository-spezifische Konfiguration -
git config --local -l
WICHTIG: Gelesen wird die Konfiguration genau in o.g. Reihenfolge. Alle vorhandenen Konfigurationen kommen zum Tragen, ABER Einstellungen in höheren Konfigurationen werden von Einstellungen in niedrigeren Konfigurationen überschrieben! D.h. die Priorität der einzelnen Einstellungen ist wie folgt: 4. Repository-spezifisch > 3. User-spezifisch II > 2. User-spezifische I > 1. System-spezifisch
Mit folgendem Befehl kann man sich anzeigen lassen aus welchen Dateien die einzelnen Einstellungen kommen:
$ git config --list --show-origin
# zeigt alle Einträge der globalen .gitconfig
$ git config --global --list
# zeigt ALLE Konfigurationen (nicht nur die globalen)
$ git config --list
# öffnet globale .gitconfig zum editieren in VIM
$ git config --global --edit
# zeigt die Lokationen aller Konfigurationen
$ git config --list --show-origin
# System, applies to entire machine and all users
$ git config --system --list
$ git config --system --edit
# User defined
$ git config --global --list
$ git config --global --edit
If not set explicitly with --file, there are four files where git config will search for configuration options:
1.) $(prefix)/etc/gitconfig
System-wide configuration file.
BEISPIEL: "C:\tools\cmder\vendor\git-for-windows\mingw32/etc/gitconfig"
2.) $XDG_CONFIG_HOME/git/config
Second user-specific configuration file.
BEISPIEL: "C:\ProgramData/Git/config"
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.
3.) ~/.gitconfig
User-specific configuration file. Also called "global" configuration file.
BEISPIEL: C:/Users/username/.gitconfig
4.) $GIT_DIR/config
Repository specific configuration file.
BEISPIEL: .git/config
If no further options are given, all reading options will read all of these files that are available. If the global or the system-wide configuration file are not available they will be ignored. If the repository configuration file is not available or readable, git config will exit with a non-zero error code. However, in neither case will an error message be issued.
The files are read in the order given above, with last value found taking precedence over values read earlier. When multiple values are taken then all values of a key from all files will be used
Siehe auch:
http://stackoverflow.com/questions/2114111/where-does-git-config-global-get-written-to