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

Re: Multiple --global config workspaces?

From
Philip Oakley <philipoakley@iee.email>
Date
Oct 11, 2022, 13:56 UTC
Message-ID
<85046d94-fa83-db7b-df64-27cf928fd08e@iee.email>
In-Reply-To
<xmqqwn96x61t.fsf@gitster.g>
On 11/10/2022 06:50, Junio C Hamano wrote:
Show 29 quoted lines
> Elsie Hupp <git@elsiehupp.com> writes:
>
>> I structure my cloned repositories based on the remote host, e.g.:
>>
>> ~/Repositories/github/cloned-repository-name
>> ~/Repositories/gitlab/other-cloned-repository-name
> The above is by definition not "global" (aka "per user").
>
> "--global" is for things that are of your personal preference, not
> "when I am working on this project, these settings apply" (which is
> suitable for "per repository").
>
> What you want is a way to say "when I am working on these projects,
> these settings apply".
>
> One way to do this would be to have
>
> 	[includeIf "gitdir:~/Repositories/github/"] path = $HOME/.githubconfig
> 	[includeIf "gitdir:~/Repositories/gitlab/"] path = $HOME/.gitlabconfig
>
> in $HOME/.gitconfig and then write in these two extra files that are
> conditionally included whatever settings you want to use for any and
> all repositories that come from GitHub or GitLab.
>
> $ git help config
>
> and look for Conditional includes, perhaps?
>
>

This use of "IncludeIf" for the Home/work case also came up in a recent Git for Windows discussion https://github.com/git-for-windows/git/discussions/4058

That discussion was about the trickiness of quoting when on the different Windows terminals/shells as the config string gets passed around (IIUC).

-- Philip

Previous: Elsie HuppNext: Reto
Message 13 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.