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.

Sign up to request clarification or add additional context in comments.

3 Comments

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.
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.
Yes, those steps would be the same for Windows.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.