DEV Community

david-zoltan for ConfigCat

Posted on • Updated on

Lazy man's guide: multiple GitHub HTTPS accounts on Windows

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 (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. 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

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.

Oldest comments (9)

Collapse
 
moopet profile image
Ben Sinclair

I don't use Windows for development, but can't use just use a key instead of HTTPS?

Collapse
 
davidzoltan profile image
david-zoltan

Sure, you are right. You can use SSH keys if you want. @arnellebalane has covered that in this post.

Do you develop on Mac or on Linux? Maybe something else?

Collapse
 
moopet profile image
Ben Sinclair

I use Macs at work (because I have no choice and it's the thing cool companies do) and Linux at home.

Thread Thread
 
davidzoltan profile image
david-zoltan

because I have no choice and it's the thing cool companies do

Yes :) Companies tend to do whatever arbitrary thing other companies do. Open offices, HR, Macs, and free food.

Collapse
 
jeikabu profile image
jeikabu

Git is definitely one of those things that gets painful on Windows. Especially if you're using some GUI client as well.

Not sure how I feel about using SSH config vs git config to select the right key, but I've mostly phased out HTTPS because of the headaches (other than for the occasional quick clone). Thanks for taking the time to dig through this.

Collapse
 
davidzoltan profile image
david-zoltan

Thanks. This is just exactly how I always felt, and it's the reason I use command line git.

For me starting with HTTPS always feels easier. It requires fewer steps I have to take than the SSH way. While I really appreciate how SSH is considered being superior.

What I discovered is doing-everything-all-the-time-perfect depletes mental and emotional energy and is my main reason for procrastination. So, I decided to enable myself to chose the easy path in certain situations, even if there exists a solution that is considered better. This mentality has helped me to accomplish not-perfect-somethings instead of perfect-nothings.

Collapse
 
anthonybro profile image
Anthony Brown

Thanks David, that was very helpful. I'm wondering how this will effect the personal access tokens on gitHub. I just I'll wait and see.

Collapse
 
dhananjayindia7 profile image
Dhananjay Porwal

Thanks buddy, I was stuck in the loop of choosing account every time, as my automated script runs in X interval. Btw, I just signed up to like you post...

Collapse
 
dvorkam profile image
Dvorkam

THANK YOU. I tried to figure this out for so long without success. For a while I tried to juggle several SSH keys, but that has issues on Windows as well, so I finally just resigned myself to deleting the git windows credentials whenever I needed to switch between the accounts. (As it didn't happen that often anyway)

This is ... beautiful, simple once per repo solution. Love it.

I signed up to this site just to say thank you and I love you.