DEV Community

Alexey Lysenko
Alexey Lysenko

Posted on

Manage multiple GitHub accounts on one Windows machine (HTTPS)

When you starting to work on commercial projects, often you have to manage multiple GitHub accounts. For comfortable push/pull your code between repositories from different accounts, we can youse simple and efficient setup.

Let's say you previously use git on your machine and configure git global config file. To check it open the terminal and :

git config --global -e
Enter fullscreen mode Exit fullscreen mode

It opens you editor, and you may see something like this:

[user]
    email = yourEmail@gmail.com
    name = Your_Name
...
Enter fullscreen mode Exit fullscreen mode

And this is great because you can push your code to GitHub account without entering credentials every time.
But what if it needs to push to repo from another account? In this case, git will reject with 403 err, and you must change your global git credentials. To make this comfortable lat set storing a repo name in a credential manager:

git config --global credential.github.com.useHttpPath true
Enter fullscreen mode Exit fullscreen mode

to check it open config one more time

git config --global -e
Enter fullscreen mode Exit fullscreen mode

you will see new config lines

[credential]
    useHttpPath = true
...
Enter fullscreen mode Exit fullscreen mode

The is it. Now when you first time push to any account you will see a pop-up
Screenshot_1

Enter specific for this repo account credentials, and this will "bind" this account for the repo. And so in your machine, you can specify as many accounts/repos as you want.

For a more expanded explanation you can see this cool video that I found on youtube:
https://youtu.be/2MGGJtTH0bQ

Top comments (0)