3

I need to connect to multiple Git servers with different credentials for my work. I have my personal repository mypersonal@github.com, my office work repository myoffice@bitbucket.com and my customer work repository mycustomer@customer.com

I need to regularly access and push code to these different repositories with different credentials (which have access to the respective repositories)

How do I configure my git client (I am using git shell - powershell on Windows) to prompt me for user id and password everytime I connect to a remote repository? Ideally, I would prefer not to have to manage certificates.

Note: I have already set my global variables. Not able to unset it now.

If git bash is preferable over git shell, I am open to that as well. I just find git shell easier to deal with since I am used to Windows environment.

TechiRik
  • 1,893
  • 6
  • 27
  • 37
  • Possible duplicate of [Multiple github accounts on the same computer?](https://stackoverflow.com/questions/3860112/multiple-github-accounts-on-the-same-computer) – Schwern Jun 21 '17 at 21:29
  • If the accounts are on different servers, all you need is an ssh key for each one. [Github has help for that](https://help.github.com/articles/connecting-to-github-with-ssh/). If you have multiple Github accounts, see [this answer](https://stackoverflow.com/questions/3860112/multiple-github-accounts-on-the-same-computer). – Schwern Jun 21 '17 at 21:33

1 Answers1

1

You can benefit from .ssh/config to differ between your git accounts over ssh. Pay attention how domains are different and keys are pointed:

#account1
Host github.com-account-one
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_account_one

#account2
Host github.com-account-two
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_account_two

For e.g. to use account1, make sure you set origin url or clone from github.com-account-one in your local repository, proper login information will follow:

 git clone ssh://git@github.com-account-one:/MyRepo/myrepo.git 
hurturk
  • 5,214
  • 24
  • 41