This is my .gitconfig as it stands now :-

 $ cat .gitconfig
    name = Shirish Agarwal
    email = [email protected]
    helper = cache --timeout=3600

This is in -

$ pwd

Obviously I have obfuscated my mail id a bit to prevent spammers etc. from harvesting my mail id here.

But let's say I have another credential for another git site (private though) and I want to have it in the global configuration, both the username and the password so that when I pull from that site it doesn't ask me for the credentials anymore.

I am guessing this is possible, but how ?

1 Answer 1


I don't think that's possible. There are global configuration options and per-repository-options. If you use different email addresses in different repositories, you need to set them on a per-repository basis.

You can configure an individual repo to use a specific user / email address which overrides the global configuration. From the root of the repo, run

git config user.name "Your Name Here"
git config user.email [email protected]

You can see the effects of these settings in the .git/config file .

The default settings are in your ~/.gitconfig and can be set like this:

git config --global user.name "Your Name Here"
git config --global user.email [email protected]


  • ok will try and let you know if it works, thanks. But that does mean it would also generate a .gitconfig in that repository as well ?
    – shirish
    Commented Oct 29, 2015 at 17:26
  • 1
    Every git repo also has a config file, it's located at .git/config and created during the repo init.
    – Jan
    Commented Oct 30, 2015 at 7:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .