Git Multiple git configurations


You have up to 5 sources for git configuration:

  • 6 files:
    • %ALLUSERSPROFILE%\Git\Config (Windows only)
    • (system) <git>/etc/gitconfig, with <git> being the git installation path.
      (on Windows, it is <git>\mingw64\etc\gitconfig)
    • (system) $XDG_CONFIG_HOME/git/config (Linux/Mac only)
    • (global) ~/.gitconfig (Windows: %USERPROFILE%\.gitconfig)
    • (local) .git/config (within a git repo $GIT_DIR)
    • a dedicated file (with git config -f), used for instance to modify the config of submodules: git config -f .gitmodules ...
  • the command line with git -c: git -c core.autocrlf=false fetch would override any other core.autocrlf to false, just for that fetch command.

The order is important: any config set in one source can be overridden by a source listed below it.

git config --system/global/local is the command to list 3 of those sources, but only git config -l would list all resolved configs.
"resolved" means it lists only the final overridden config value.

Since git 2.8, if you want to see which config comes from which file, you type:

git config --list --show-origin