• Menu
  • Skip to right header navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer

LEVELPRIME

Make technologies

Header Right

  • Italiano
  • Home
  • Services
  • Blog
  • Home
  • Services
  • Blog

Header Right

  • Italiano

Multiple github accounts on same machine (windows os) without using SSH keys

By Filippo Iovine (20 November, 2018) in git, windows

Having some problems to set multiple github accounts on my windows machine and with the target to not use any SSH approach, I chose to play with GIT credential helpers to fit the best one for my needs.

Final solution, in my case, was to set GIT using git-credential-store helper: a credential helper that stores GIT credentials locally on disk.

Be aware that probably a credential helper is already in place in your GIT environment and probably that is GIT Credential Manager (GCM). That’s because GCM is installed alongside GIT for Windows that updates GIT system config file accordingly (credential.helper=manager is added into the GIT system config file, usually located in \Program Files\Git\mingw64\etc\gitconfig).

 

Clean GIT config file from previous helpers

Open a dos CLI as administrator and unset helper from GIT system config:

git config --system --unset credential.helper

 

Set new credential.helper=store into global config file:

git config --global credential.helper store

 

Finalize GIT to handle multiple github accounts.

To complete the job, you need to set remote url to https like below or edit local git config file (.git/config) looking for [remote … ] sections and add missing USERNAME@:

git remote set-url origin https://USERNAME@github.com/USERNAME/REPO.git

Now push to force git asking for credentials:

git push

 

 

Cons

With the store credential helper, GIT stores credentials in the GIT credential file (usually located in %HOME%\.git-credentials) in a unencrypted format (password included).

So be careful with that and protect credential file at least by filesystem permissions.

 

Why can we not use GCM to handle multiple github accounts?

GCM saves GIT accounts (encrypted) credentials into Windows Credential (WC) wallet database.

When GCM is set and GIT requests credentials:

  1. GCM is invoked, a PAT (Personal Access Token) is requested to github and saved remotely in the Settings/Developer settings/Personal access tokens section on your github account.
    Locally PAT account data is stored in your WC wallet as PersonalAccessToken/[PASSWORD] user with URI key internet/network address=git:https://github.com.
  2. In case 1) won’t be performed (or interrupted) then GIT command line asks for credentials (USER NAME and PASSWORD) to locally saves those in your WC wallet as [USER]/[PASSWORD] account with URI key internet/network address=git:https://github.com.

Performing same operation with another github account, GCM stores account info using again same URI internet/network address=git:https://github.com overwriting previous one (WC can save one account per URI).

Finally, GCM does not support multiple users per Uri (as reported in Microsoft/Git-Credential-Manager-for-Windows:issue 363).

Filed Under: git, windows Tagged With: credentials, git, multiple accounts, windows

Filippo Iovine

About Filippo Iovine

Analyst and software developer, stubborn, till the end because everything is possible and if not then there is a bug to find.

« How to move files/directories from one git repository into another preserving history

Reader Interactions

Primary Sidebar

Categories

  • git
  • windows

Recent Posts

  • Multiple github accounts on same machine (windows os) without using SSH keys
  • How to move files/directories from one git repository into another preserving history

Footer

Pages

  • Home
  • Services
  • Blog

Contacts

  • Rome (Italy): +39 06 66178031
  • Oristano (Italy): +39 0783 71339
  • London (UK): +44 (0)208 144 9929
  • Antwerp (Belgium): +32 3 633 1196
  • info@levelprime.com

Policies

  • Privacy Policy
  • Cookie Policy

Copyright © 2023 @ Level Prime srl