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
Another option to get git
to work with multiple names / emails is by aliasing git
and using the -c
flag to override the global and repository-specific config.
For example, by defining an alias:
alias git='/usr/bin/git -c user.name="Your name" -c user.email="name@example.com"'
To see whether it works, simply type git config user.email
:
$ git config user.email
name@example.com
Instead of an alias, you could also put a custom git
executable within your $PATH
.
#!/bin/sh
/usr/bin/git -c user.name="Your name" -c user.email="name@example.com" "$@"
An advantage of these method over a repository-specific .git/config
is that it applies to every git
repository when the custom git
program is active. In this way, you can easily switch between users/names without modifying any (shared) configuration.