Skip to contentSkip to conversation

git config --global not picking up includes

PATCH New Jim Garrison 2 participants 2 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

I have found that git config --global does not pick up any include directives in the git config file.

For instance, my ~/.gitconfig contains the following:

[include]
path = /home/garrison/gitconfig-include

And ~/gitconfig-include in turn contains

[user]
name = Jim Garrison

However, when I pass the --global flag to git config, my name is not picked up:

    $ git config --global user.name
    $ git config user.name
    Jim Garrison

If I instead replace .gitconfig with the contents of gitconfig-include (and in turn remove the include step), everything works as expected.

    $ git config --global user.name
    Jim Garrison
    $ git config user.name
    Jim Garrison

I am using the latest git master, built on Debian jessie.

#1 lore raw

PATCH 1/1 git-config: better document default behavior for `--include`

Quoted 2 lines · Jim Garrison

I have found that git config --global does not pick up any include directives in the git config file.

That's by design. You asked for the entries in a specific file, and we do not follow any includes by default in that case. You can use --include if you want to follow includes.

The documentation is quite misleading here, though. Here's a patch.

-- >8 --
Subject: git-config: better document default behavior for --include

As described in the commit message of 9b25a0b (config: add include directive, 2012-02-06), the --include option is only on by default in some cases. But our documentation described it as just "defaults to on", which doesn't tell the whole story.

---
 Documentation/git-config.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/git-config.txt +3 -1
index 9dfa1a5..d42c062 100644
@@ -215,7 +215,9 @@ See also <<FILES>>.
 
 --[no-]includes::
 	Respect `include.*` directives in config files when looking up
-	values. Defaults to on.
+	values. Defaults to `off` when a specific file is given (e.g.,
+	using `--file`, `--global`, etc) and `on` when searching all
+	config files.
 
 [[FILES]]
 FILES
Signature · 1 line
2.2.1.425.g441bb3c