Can I specify multiple users for myself in .gitconfig?

后端 未结 20 2575
无人及你
无人及你 2020-11-22 06:33

In my ~/.gitconfig, I list my personal email address under [user], since that\'s what I want to use for Github repos.

But, I\'ve recently s

20条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 06:45

    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
    

提交回复
热议问题