Multiple git config

Global git config at ~/.gitconfig

[user]
    name = Nhan Cao
    email = [email protected]

Create a config file if it does not exist.

To assume you need all commit in the specific folder tree use another author.

  • Create a new git config file in that specific folder. The example: I place in ‘eric’ folder: /Volumes/Data/Projects/eric/.gitconfig
[user]
    name = Eric Cao
    email = [email protected]
  • Then update the global git config file like
[user]
    name = Nhan Cao
    email = [email protected]
[includeIf "gitdir:/Volumes/Data/Projects/eric/"]
    path = /Volumes/Data/Projects/eric/.gitconfig

You can put a lot of config file to global

[user]
    name = Nhan Cao
    email = [email protected]
[includeIf "gitdir:/Volumes/Data/Projects/eric/"]
    path = /Volumes/Data/Projects/eric/.gitconfig
[includeIf "gitdir:/Volumes/Data/Projects/boy/"]
    path = /Volumes/Data/Projects/boy/.gitconfig
[includeIf "gitdir:/Volumes/Data/Projects/girl/"]
    path = /Volumes/Data/Projects/girl/.gitconfig

For windows

[includeIf "gitdir:D:/Projects/eric/"]
    path = D:/Projects/eric/.gitconfig

Leave a Reply

Your email address will not be published.Required fields are marked *