1

I have a question regarding managing two Github accounts in my machine (office and personal). Whenever I create a repo in personal am I supposed to create a new ssh key(As my office git account username and email are global)? Using windows credentials way I'm prompted to enter the username and password for the first time I do remote push then onwards I need not have to do that for that particular repo. I wanted to try by ssh(to avoid entering my git account credentials for the first time) or can I stick with the windows credential manager way?

1 Answer 1

1

Whenever I create a repo in personal am I supposed to create a new ssh key(As my office git account username and email are global)?

No: the SSH key remains the same and is used to authenticate you to your personal GitHub account.

You only need to register that key in your ~/.ssh/config file:

Host perso
  Hostname github.com
  User git
  IdentityFile ~/.ssh/myPersoKey

Then, in your local cloned repository:

cd /path/to/local/clone
git remote set-url origin perso:<me>/<myrepo>

Then a git push will use the SSH URL, with the right perso key.

3
  • In fact your reply confirmed the way i tried after posting the question. Thanks a lot VonC for taking time out to reply to my question. Commented Feb 17, 2021 at 5:19
  • VonC im using windows. The above step to set-url is for macbook?. In windows i created repo internally and just by adding the ssh url from github repo established the connection. Thus, i could push the code into the github repo without any requirement for entering my github account credentials. Commented Feb 17, 2021 at 5:36
  • 1
    Yes, those steps would be the same for Windows.
    – VonC
    Commented Feb 17, 2021 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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