Issue
Following up on Is it possible to include a file in your .gitconfig, are there any exceptions to use include
in the .gitconfig
file? Why mine is not working?
$ cat .gitconfig
[include]
path = /tmp/.gitconfig.id
$ cat /tmp/.gitconfig.id
[user]
name = Me
email = [email protected]
$ git config --global user.name | wc
0 0 0
$ git -v
git version 2.39.2
$ uname -rms
Linux 6.1.0-9-amd64 x86_64
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
I.e., I found myself can use include
in the .gitconfig
for all sections except [user]
.
Solution
Respect
include.*
directives in config files when looking up values. Defaults tooff
when a specific file is given (e.g., using--file
,--global
, etc) andon
when searching all config files.
I.e. either omit --global
:
git config user.name | wc
or add --includes
:
git config --global --includes user.name | wc
Answered By - phd Answer Checked By - Marilyn (WPSolving Volunteer)