Lazy man's guide: multiple GitHub HTTPS accounts on Windows
Tags: git, github, https, windows
Published: 2019-08-10 10:02:03

Using multiple GitHub account's on Windows sucks by default. If you are tired of  Window's Credential Manager storing only one account's credential for git:https://github.com then here is a 1-minute fix for you.

##TL;DR

If you know what you're doing just:
- delete your GitHub credentials from Windows Credential Manager
- run `git config --global credential.github.com.useHttpPath true`
- continue coding

If you need more detailed instructions and learn about the background just read on.


##The full story

I'm juggling with multiple GitHub repos on a daily basis. They all require different credentials. It's not only the repos of ConfigCat, my [feature flag service](https://configcat.com) (a great LaunchDarkly alternative "by the way") but my other projects too. If you're a developer at heart, I'm sure you know what I'm talking about. I never really liked how the credential manager on Windows stores one single GitHub account for all my repos by default.

Just came through @arnellebalane's great post about [setting up multiple GitHub accounts the nice way](https://dev.to/arnellebalane/setting-up-multiple-github-accounts-the-nicer-way-1m5m). His solution is based on SSH keys and is pretty thorough.

While I would never publicly admit that I'm lazy, I happen to know a quick and dirty solution here. I decided to share the "lazy man's guide" to set up multiple GitHub accounts on Windows. While @arnellebalane's solution is really nice, you might be interested in a more basic approach...

###The problem

If you're using Windows Credential Manager to store your username/password for your GitHub account, and you have to work with different GitHub accounts for different projects, then I'm sure you've already experienced

```
fatal: Authentication failed for https://www.github.com/name/repo.git
```

Usually, this happens when you try to push to _one_ of your repositories in the name of _another account_ that is for your _other_ project.

The root problem is that Windows Credential stores the one same account for all your GitHub repositories.

###The solution

There is a simple, three steps solution that will help you store multiple different GitHub accounts, one for each of your GitHub repos.

Simple 3 step solution:
- remove your current GitHub credentials from Windows Credential Manager
- tell Windows to store different accounts for each of your GitHub repos
- provide your username, password once again for each repo when you are prompted for your credentials - this is the last time you need to do that

####Removing current GitHub credentials from Windows Credential Manager

Go to `Windows Credential Manager`, open the `Windows Credentials` tab, locate `git:https://github.com`, open the entry, and click `Remove`.
 
![Windows Credential Manager](https://thepracticaldev.s3.amazonaws.com/i/3xrbl69zb6tzlq9fdcvv.png)

This will remove your GitHub credentials from the credential manager.

####Tell Windows to store different accounts for different repos

Issue the following git command:

```
git config --global credential.github.com.useHttpPath true
```

Now, Windows will store different logins for each of your GitHub repos.

####Reauthenticate

Just work on your project. Whenever GitHub asks you for your credentials, just type your username and password. Windows will store them and you never ever have to provide them again for this repo.