git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Multiple --global config workspaces?

From
EHElsie Hupp <git@elsiehupp.com>
Date
Oct 11, 2022, 18:41 UTC
Message-ID
<909C9446-F04D-4037-B12D-C97A68EC5AB3@elsiehupp.com>
In-Reply-To
<03B277AB-DE33-443D-AC9C-FAB7A2F93AB3@elsiehupp.com>
I just opened an issue on the “Git Book” repository suggesting the addition of a section discussing [includeIf], if anyone here would like to comment there:
https://github.com/progit/progit2/issues/1801
Show 64 quoted lines
> On Oct 11, 2022, at 12:55 PM, Elsie Hupp <git@elsiehupp.com> wrote:
> 
> Hi Junio, Reto, Jeff, Philip, et al,
> 
> Cool, thanks!
> 
> I was using the “Git Book” documentation, not the manpage, since (a) the “Git Book” is more user-friendly, and (b) it’s higher on the DuckDuckGo results for “git config", i.e.:
> 
> https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration
> 
> Even then, I don’t see includeIf in the first two web-based versions of the manpage for the DuckDuckGo query "man git-config":
> 
> https://linux.die.net/man/1/git-config
> https://manpages.org/git-config
> 
> Though includeIf does appear in the manpage on my local system, as well as in the web-based Arch manpage (which is the fifth result):
> 
> https://man.archlinux.org/man/git-config.1
> 
> And includeIf does appear in the official documentation (which is the first DuckDuckGo result for "man git-config”—I much prefer web mirrors to using man in the terminal):
> 
> https://git-scm.com/docs/git-config#_conditional_includes
> 
> So in summary it seems like a big part the issue I had is that the documentation for conditional includes has somewhat lacking SEO, i.e. if someone is familiar with the --global config keywords and googles that, they are unlikely to find the section for conditional includes. And, additionally, conditional includes are a new enough feature that they don’t appear in the higher-ranking web-based manpages, neither of which display the version of Git they pertain to. (Maybe someone could poke them about this, but I’m not sure the best way of doing so.)
> 
> As an aside, looking through the full documentation I see that I can also do:
> 
> [includeIf "hasconfig:remote.*.url:https://github.com/**”] path = ./Repositories/github/.gitconfig
> [includeIf "hasconfig:remote.*.url:https://gitlab.com/**”] path =  ./Repositories/gitlab/.gitconfig
> 
> And, conveniently, [includeIf "gitdir:github/“] also expands to [includeIf “gitdir:**/github/“], so I don’t have to specify [includeIf "gitdir:~/Repositories/github/“]. (I’m not sure how to represent the trailing slash in bash syntax, but it helps, too!)
> 
> Something more consistent with my initial use case might be a hypothetical feature like the following (apologies for dubious syntax):
> 
> [user "gitdir:github/"]
> 	email = "elsiehupp.github@example.com"
> 
> Or something like:
> 
> if "gitdir:gitlab/" email = "elsiehupp.gitlab@example.com”
> 
> In other words, part of the discoverability issue is that I wasn’t looking for a conditional _include_ so much as a conditional statement more generally.
> 
> I also tried:
> 
> [include] path = $GIT_COMMON_DIR/../.gitconfig
> 
> …only to discover that $GIT_COMMON_DIR is not set automatically. Is there some way of automatically describing a path relative to any given cloned Git repository?
> 
> And I tried the following to no avail (despite both paths resolving when using cat):
> 
> [includeIf "gitdir:github/"] path = ./**/github/.gitconfig
> 
> [includeIf "gitdir:github/"] path = ./*/github/.gitconfig
> 
> So it would be nice if in addition to being able to use bash wildcards in [includeIf “gitdir”] one could use bash wildcards in inclusion paths, as well.
> 
> I guess for the time being what I’ll stick with is this:
> 
> [includeIf "gitdir:github/"] path = ./Repositories/github/.gitconfig
> [includeIf "gitdir:gitlab/"] path = ./Repositories/gitlab/.gitconfig
> 
> Best,
> Elsie Hupp
Previous: Elsie HuppNext: Jeff King
Message 5 of 14 in “Multiple --global config workspaces?”
  1. Elsie HuppOct 11, 2022
  2. Junio C HamanoOct 11, 2022
  3. Jeff KingOct 11, 2022
  4. Elsie HuppOct 11, 2022
  5. Elsie HuppOct 11, 2022
  6. Jeff KingOct 14, 2022
  7. Matthias AßhauerOct 15, 2022
  8. Jeff KingOct 15, 2022
  9. Elsie HuppOct 18, 2022
  10. Jeff KingOct 18, 2022
  11. Elsie HuppOct 20, 2022
  12. Elsie HuppOct 20, 2022
  13. Philip OakleyOct 11, 2022
  14. RetoOct 11, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.