Multiple Git identities
Each Git commit contains information about the author of the commit, among other things. A person's real name and email address are usually set as the Git identity.
Git offers the option of setting up multiple identities per user. This means, for example, that private projects can be committed with the private e-mail address. Projects in a business context can be committed with the business e-mail address.
In the following examples, the configuration file ~/.gitconfig
is edited.
Identity per path
The identity can be set per path.
In the following example, the directory structure under ~/projects
is used:
projects
├── private
└── work
The configuration file ~/.gitconfig
can look like this:
.gitconfig
.gitconfig
~.gitconfig
1234
[includeIf "gitdir:~/projects/work/**"]
path = ~/.gitconfig-work
[includeIf "gitdir:~/projects/private/**"]
path = ~/.gitconfig-private