0

This is my .gitconfig as it stands now :-

 $ cat .gitconfig
[user]
    name = Shirish Agarwal
    email = shirishagxyz@gmail.com
[credential]
    helper = cache --timeout=3600

This is in -

$ pwd
/home/shirish

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

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 your@email.com

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 your@email.com

Source

  • 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 Oct 29 '15 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 Oct 30 '15 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.