Is it possible to configure user.name and user.email per wildcard domains in .gitconfig?

前端 未结 5 450
不思量自难忘°
不思量自难忘° 2021-01-31 03:00

I have a work computer, and it\'s configured globally to use my work email and name when committing. This is good. However, I\'d like to make some sort of rule that says, \"if t

5条回答
  •  日久生厌
    2021-01-31 03:19

    Git 2.13 adds support for conditional config includes. If you organize your checkouts into directories for each domain of work, then you can add custom settings based on where the checkouts are. In your global git config:

    [includeIf "gitdir:code/work/"]
        path = /Users/self/code/work/.gitconfig
    

    And then in ~/code/work/.gitconfig:

    [user]
        email = self@work.com
    

    And of course you can do that for as many domains of work as you like.

提交回复
热议问题