How to connect GitHub accounts with Visual Studio?

In this post we will learn how to connect GitHub accounts with Visual Studio and and it involves adding GitHub accounts to Visual Studio 2019.

Note that this is not a GitHub Visual Studio extension. This is more of a GitHub Visual Studio integration. This post will answer some of your below questions.

  • How to push code to GitHub from Visual Studio?
  • Linking my GitHub account to Visual Studio?
  • How do I upload a Visual Studio project to GitHub?

Interesting read – Read more about Visual Studio for Mac.

In case you are running short on time, check out the mini video version of this post.

On Nov 2020, the Visual Studio team announced that it now supports adding of GitHub accounts to VS 2019. The support comes with full integration of GitHub accounts with Visual Studio. This creates a GitHub Visual Studio integration

This feature is available from VS Studio 2019 version 16.8 onwards. From this version onwards, you can add two types of accounts directly from Visual Studio.

Which type of GitHub accounts are supported?

There are 2 types of accounts supported

  • GitHub accounts
  • GitHub Enterprise accounts

With this integration in place, the GitHub accounts work seamlessly just like you would add your Microsoft accounts.

This is a welcome feature as it will now be easy to access our GitHub resources from within Visual Studio itself.

How to add GitHub accounts to Visual Studio

There are 2 ways to add your accounts

Add GitHub account from File -> Account Settings

You can add it from File -> Account Settings. In this way, when you do use GitHub in the future you can add it directly to the workflow via the account selector.

With this option, a new web browser window will open where you will have to enter your GitHub credentials. On successful authentication, your GitHub account will be added and will become available in the account selector section.

Add GitHub accounts to Visual Studio add repository
Source: Microsoft docs

Add GitHub account from Git Tooling

Starting with VS 2019 version 16.8, Git tooling is now the default source controller in Visual Studio 2019. This announcement was also done in Nov 2020.

With the new Git tooling you can create a repository and add your account via the same dialog box.

Visual Studio Create Git Repository
Source: Microsoft docs

After successful authentication and linking your account, it will be displayed with your other accounts as well.

The Git tooling allows you to access all the Git features using a top level Git menu. The shortcut key for the same is Alt + G. There are several sub menus in it like Local Repositories, Open Repository In, etc. You can toggle between your local Git repositories which were recently opened in VS.

Git VS Menu
Source: Microsoft docs

Other features of Git Tooling

By default, Git is now the main version controller in Visual Studio 2019. This feature set was developed based on the user community feedback. This will affect all users.

The new Git menu allows you to

  • Create repositories
  • Open repositories
  • Clone repositories
  • Manage branches
  • Resolve merge conflicts
  • Commit and push changes to your code,
  • Get latest updates on remote repositories

How to add GitHub Enterprise accounts to Visual Studio

Just like GitHub accounts you can add an enterprise account from File -> Account Settings as well as from the account selector section.

But before this you need to enable support for GitHub Enterprise via the Tools -> Options menu.

To do this go to Tools -> Options -> Environment -> Accounts

Then tick the “Include GitHub Enterprise Server accounts” checkbox as shown below

Add enterprise accounts to Visual Studio
Source: Microsoft docs

After selecting the above option, the Add Account flow will open a new dialog box. It will give you an option to log via your GitHub Enterprise account.

You can type in the server URL and add the account by signing in via the browser.

Constraints while using GitHub with Visual Studio

Multiple GitHub Enterprise accounts can be added to Visual Studio. The only requirement is that each account endpoint should be different.

As of now, GitHub accounts and GitHub Enterprise cannot be used as personalization accounts from Visual Studio. Hence if you want your settings on multiple machines, you will need to add your Microsoft account on all of them.

Only one GitHub account can be added to Visual Studio just like online on the GitHub client.

If you want to access other resources which are on another account, then you’ll need to remove that GitHub account from Visual Studio. Then you need to sign out from the GitHub website (github.com). Then you have to again add the new GitHub account to Visual Studio.

Upcoming features of VS GitHub Integration and roadmap

The Visual Team will be trying to add single sign-on (SSO) experience in future versions along with user feedback.

You can submit your feedback in 2 ways

Roadmap

You can also checkout the roadmap on the developer conversation page

Summary

Making Git Tooling the default source control explorer has mixed reactions in the developer community. Some of them think they were happy working with the old Team explorer interface while some think that this is a new welcome addition for GitHub users.

You can share your experiences too while using this new feature using the comments section below. Till we meet again on another post, bye for now.

Hitesh Boricha

I have a little over a decade experience in the IT industry. Having worked in various roles in this industry, I am passionate about technology.

One thought to “How to connect GitHub accounts with Visual Studio?”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.