问题
The reference https://git-scm.com/docs/git-config says configuration for git are conserved by three scopes, system, global and project specific.
I wonder is there any other way to separate more specific scopes between global and project.
For example, I have many project related to my official work and at that time I need user.name = "NAME IN CORP". OTOH others need user.name = "NAME IN PUBLIC".
The problem is projects which belong to two scopes that I mentioned (work, public) are too many to specify project-scope one by one. Is there any effective way to solve it?
回答1:
Since git 2.13, it is possible to solve this using newly introduced Conditional includes.
An example:
Global config ~/.gitconfig
[user]
name = John Doe
email = john@doe.tld
[includeIf "gitdir:~/work/"]
path = ~/work/.gitconfig
Work specific config ~/work/.gitconfig
[user]
email = john.doe@company.tld
来源:https://stackoverflow.com/questions/48018041/elegant-way-to-conserve-gitconfig-separatly