How can I configure different emails for different Git servers or repositories?

“.gitconfig” in your home directory

If you’re like me, and you wanted to configure a different email for different repo’s the first place you look is ~/.gitconfig. This is the default configuration for git for your account. You can set your default user name there, as well as helper apps and other good stuff. But what if you want to change the email or user name for different repositories?

“git config” from the command line

Once you have a local clone of a git repository there is another config file in <my_repo_location>/.git/config. You can edit that manually, or use git to edit it for you…

$ cd <my_repo_location>
$ git config "My Name"
$ git config ""
$ tail -n 3 .git/config
    name = My Name
    email =

You can also edit the global defaults in a similar way…

$ git config --global "My Default Name"
$ git config --global ""
Category(s): Command Line, Git
Tags: , ,

Leave a Reply

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



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam protection by WP Captcha-Free