Skip to content

Instantly share code, notes, and snippets.

@Tset-Noitamotua
Last active May 11, 2017 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tset-Noitamotua/815ac565b93dd3cb4118101f6fb0f96a to your computer and use it in GitHub Desktop.
Save Tset-Noitamotua/815ac565b93dd3cb4118101f6fb0f96a to your computer and use it in GitHub Desktop.
HOW TO - GIT: Ey man, where is my .gitconfig file?

HOW TO - GIT: Ey man, where is my .gitconfig file?

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

  1. System-spezifische Konfiguration - git config --system -l
  2. User-spezifische Konfiguration I - git config --global -l
  3. User-spezifische Konfiguration II - git config --global -l
  4. 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

Befehle zum anzeigen und bearbeiten der Git Konfiguration

# 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

Aus der original GIT Doku

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

SOURCE: https://git-scm.com/docs/git-config#FILES

Siehe auch:

http://stackoverflow.com/questions/2114111/where-does-git-config-global-get-written-to

http://stackoverflow.com/questions/17756753/where-do-the-settings-in-my-git-configuration-come-from/35670933#35670933

http://stackoverflow.com/questions/26824231/what-is-the-priority-of-git-project-global-and-system-variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment