Elegant way to conserve .gitconfig separatly?

两盒软妹~` 提交于 2021-02-19 08:58:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!