I have 2 GitHub accounts. How can I use both when I am working in VS Code?

Edit #1: 2021|JUNE|06th @12:39am (PST)
Edit #2: 2021|JULY|15th @ 4:46:31 (UTC/GMT)



“As is often the inherent nature of technology, VS Code Changed, consequently, the original answer was rendered deprecated, and was unhelpful, possibly even confusing to the users attempting to implement the answer as a solution, as it no longer worked in updated VSCode Versions. As of JULY 2021 I have edited this answer twice now, in an attempt to maintain a correct, current, and relative answer.”


Steps 1 & 2 Include:

…a detailed description of how to configure your projects for two different GitHub accounts. and a great extension to use that helps Developers maintain the correct GitHub account information for their projects that span across multiple accounts

Quickly Find Out What You Need to Know

For a Quick Solution Just Read Step #3, if you have issues you can then go back to steps 1 & 2:

In a nutshell, Step #3 demonstrates how the Logging in & out Processfor different GitHub Accounts, works. For experienced VS Code users, and Git/GitHub users, this should be sufficient enough, and the rest is TL;DR, however I added quite a bit more, because there is a good deal of info around this topic that newer programmers will likely need.


“Not only is it possible to easily, and effectively use 2 different GitHub accounts w/ VSCode, it can be done using the VS Code GUI.”

The Long Answer:

Firstly I already assume that you have your GitHub account working with VSCode, which means you have created a PAT in GitHubyou have downloaded the GitHub issues & Pull Requests extensionand authorized VSCode to be approved by GitHub. In other words, I assume that your issue is not to git GitHub working with VS Code, but rather to get two GitHub accounts working in a VS Code environment, where you have already got one account working.

The biggest problem people have using two accounts, is configuring each project for a different account. Often times they will get it working, just to be confused later down the road. I will share my configuration, and an extension I will use, that I personally have found to be a sound & full proof method.


First off, configure your local .gitconfig files on your machine by executing the following commands (use which ever account you consider to be your primary account, or if one account isn’t yours, then use your account to execute the commands below).

NOTE: It is fine if the worktree command doesn’t work, that just means you just don’t currently have a worktree .gitconfig file setup, which means that you probably don’t need to have one.
~$ git config --global user.name "urGitHubUsrName"
~$ git config --global user.email "urGitHubEmail@foobar.com"

~$ git config --local user.name "urGitHubUsrName"
~$ git config --local user.email "urGitHubEmail@foobar.com"

~$ git config --worktree user.name "urGitHubUsrName"
~$ git config --worktree user.email "urGitHubEmail@foobar.com"

STEP #2: Extensions

Acquire the following extension from the VS Code marketplace.

Git-Autoconfig forces developers to configure git at the start of every project, you will be asked for your Git Credential every time you open, create, or clone a new project. If you have a project it hasn’t configured for you that was preexisting, it has a couple commands to notify it to configure the .gitconfig for that project with your email and GitHub username.

The Reason I prefer to use Git-Autoconfig is that it always configures Git correctly. I never forget to assign the correct email and username to a project, and it opens a textbox at the top of the editor for you so you never have to use the Git CLI.

Git-Autoconfig will automatically set credentials for each new project you clone, or create, however, you need to make sure that it is already configured in your current project. You will individually set an account username and email for each project. To set the git credentials for Git-Autoconfig hit the F1 key to open the Quick-input Menu, and type “git autoconfig set”. Select: Set Config.

EDIT: (Added the paragraph below July-16th-2021)

I found, what is IMO, the best way to configure the Git-Autoconfig extension. Add the configuration in the code block below to your settings.json file. The configuration is an array of JS objects. Each object represents a Git account, or in this case, a GitHub account. The objects have two properties, that are typical settings for standard .gitconfig files:

1. “user.email”
2. “user.name”

Use the configuration as seen below to add your 2 (or 3, or 4,etc…) accounts to the Git-Autoconfig Extension.


    "git-autoconfig.configList": [
              "user.email": "DevJay@Dyslexia.com",
              "user.name": "DevJay"
              "user.email": "JayDev@isAwesome.com",
              "user.name": "JayDev"

NOTE: The configuration above enables Git-Autoconfig to allow you to choose a git configuration from a selection that contains the correct settings for your github accounts. Git-Autoconfig knows what your account settings are, because you configured Git-Autoconfig to know, by entering the correct information in the configuration above. If this sounds a little confusing, that is because at first it is. If you just use the git CLI, and the command git config user.email you will only ever be able to set a configuration for one account at a time. Git-Autoconfig gets around this by auto configuring a .gitconfig file, that’s in every project directory when using VSCode. If you configure, and use Git-Autoconfig correctly, then you don’t really need to understand the rest.”

the start of every newly created project, or at the every at the start of every project, with the option to select the proper configuration for the correct GitHub account for the new project.”_

You can also use the Git-Autoconfig extension to see what account the project is set to by using Git-Autoconfig quick input command: Get Configif it doesn’t display the right configuration for the right account in the notifications toast pop-up, then use the Get Auto Config _set config command from the quick input, as explained above to configure the project to have the correct account credentials.

As stated above you should already have the – GitHub Pull Requests and Issues installed and working,

I want to touch on this extension quickly before moving on. Personally I feel this extension should be called GITHUB SUPPORT rather than “GitHub Pull Requests and Issues”as “GitHub Pull Requests and Issues” doesn’t really do the extension justice, in terms of making it known that it is an important app for GitHub users to have. It has the mechanisms needed to help users through the GitHub PAT authorization process, as well as other important stuff. Much of what this extension offers can be used through the command-line, however, this extension lets users use GitHub features through the VS Code UI, or rather GUI.

STEP #3: Bread & Butter

Here is your bread, and butter. This is what most people miss, and the info most people are loogin for, and it is unbelievably simple, yet people overlook it a lot.

There is a “not so well known” tool/feature that VS Code VSCode Tool/Feature that VSCode documents poorly, as it is in a single place, “which is a release note that is roughly 18 month old”. I took me a long time to find anysort of reference, so I could know the correct semantics when referring it.

You can open the Account Context Menu by clicking on the user icon that is located at the bottom of your activity-bar (See the picture w/ an arrow below):

enter image description here
enter image description here

Leave a Comment