Reputation: 959
My ~/.gitconfig
contains this include
section to inherit from a team-wide config file.
[include]
~/.gitconfig.team
However, I have personal repos where I don't want to inherit from this .gitconfig.team
.
Is there a way I can override/force unset this section in my personal repos? E.g., something I can add to .git/config
in personal_project/
?
I'm interested in a solution where I modify configs in my personal repos instead of my team repos.
Upvotes: 4
Views: 1236
Reputation: 767
As of git 2.13, you can use conditional configuration includes in order to achieve what you're asking.
For instance, if you keep your personal repos in a particular directory, you could introduce a git config to override the entries in your team configuration:
[include]
~/.gitconfig.team
[includeIf "gitdir:personal_project/"]
~/.gitconfig.personal
Alternatively, if you keep your team repos in a particular directory, you could instead just change your team configuration to use includeIf
instead of include
:
[includeIf "gitdir:team_project/"]
~/.gitconfig.team
Upvotes: 0
Reputation: 66170
Git config includes operate:
as if its contents had been found at the location of the include directive
That means you can't override/remove the include itself, as as soon as it's found the contents of the included file are injected/loaded.
You can of course override the settings it contains in a more specific config file:
# ~/.git.config.team
[user]
name = name
Locally, via git config user.name nic
# /some/project/.git/config
[user]
name = alias
Yielding:
/some/project $ git config user.name
alias
/some/project $
Upvotes: 1