Επεξεργασία

Κοινή χρήση μέσω


Add your GitHub accounts to your Visual Studio keychain

In this article, you learn how to add your public GitHub or GitHub Enterprise account to your Visual Studio keychain. After you add your account, you'll be able to track your code changes in GitHub repositories, right from Visual Studio. You can also create and use GitHub Actions for deployment automation.

Adding public GitHub accounts

You can add your public GitHub account at any point, after you've signed into Visual Studio with a Microsoft account, work account, or school account.

If you have GitHub Copilot installed, you can add a GitHub account by selecting Add GitHub account to Visual Studio from the GitHub Copilot status icon, even if you haven't signed into Visual Studio with a Microsoft account, work account, or school account.

Add a GitHub account from the Account settings dialog:

  1. Open the Account Settings dialog by going to File > Account Settings....

  2. From the All Accounts submenu, select + Add to add an account, and select GitHub.

    Select add GitHub account

  3. You'll be redirected to the browser, where you can sign in with your GitHub credentials. After you sign in, you'll get a success window in the browser, and you can return to Visual Studio.

    Success window in browser

  4. Your GitHub account will now be present in the All Accounts submenu.

    Both accounts showing

  1. Open the Account Settings dialog by going to File > Account Settings....

  2. From the All Accounts submenu, select + Add to add an account, and then select GitHub.

    Screenshot showing the Add GitHub account option.

  3. You'll be redirected to the browser, where you can sign in with your GitHub credentials. After you sign in, you'll get a success window in the browser, and you can return to Visual Studio.

    Success window in browser.

  4. Your GitHub account will now be present in the All Accounts submenu.

    Screenshot showing both accounts on the Account settings dialog.

Add a GitHub account from the profile card:

If you're not already signed in to Visual Studio, select the Sign in link in the upper-right corner of the Visual Studio environment and use a Microsoft account, work account, or school account to sign in.

Screenshot showing not signed in to Visual Studio.

Then, follow these instructions to add your GitHub account.

  1. Select the icon with your profile name in the upper-right corner of the Visual Studio environment, select Add another account, and then select GitHub.

    Screenshot of using Add another account option to add a GitHub account.

  2. You'll be redirected to the browser, where you can sign in with your GitHub credentials. After you sign in, you'll get a success window in the browser, and you can return to Visual Studio.

    Screenshot of the success window in browser.

  3. Your GitHub account will now be present in your profile card.

    Screenshot showing both accounts on the sign in profile.

Enabling GitHub enterprise accounts

By default, Visual Studio only has public GitHub accounts enabled. Use the following steps to add a GitHub Enterprise Server account or an account associated with .ghe.com endpoints.

  1. To enable GitHub enterprise accounts, go to Tools > Options and search for the Accounts options.

    Screenshot of GitHub Account.

  2. Then, check the box to Include GitHub Enterprise Server accounts. The next time you go to your Account Settings and try to add a GitHub account, you'll see options for both GitHub and GitHub Enterprise.

    Screenshot showing Sign in with GitHub Enterprise.

  3. After you enter your GitHub Enterprise server address, select Sign in with your browser. There, you can sign in using your GitHub Enterprise credentials.

  1. To enable GitHub enterprise accounts, go to Tools > Options > Accounts.

    Screenshot of GitHub Account.

  2. Then, check the box to Include GitHub Enterprise accounts. The next time you go to your Account Settings and try to add a GitHub account, you'll see options for both GitHub and GitHub Enterprise.

    Screenshot showing the Sign in with GitHub Enterprise.

  3. After you enter your GitHub Enterprise URL, select Sign in with your browser. There, you can sign in using your GitHub Enterprise credentials.

Note

To add an account to access github.com resources, such as github.com/enterprises/*, follow the steps for adding public GitHub accounts.

Adding GitHub Enterprise Managed User (EMU) accounts

You can add your GitHub EMU account if you're already signed into Visual Studio with a Microsoft account, work account, or school account.

  1. Select the icon with your initials in the upper-right corner of the Visual Studio environment. Then, select Add another account > GitHub.

    Screenshot of adding Enterprise Managed User.

  2. You'll be redirected to the browser, where you can sign in with your GitHub EMU credentials.

You can use the Account Settings dialog to manage your accounts:

  1. Select the icon with your initials in the upper-right corner of the Visual Studio environment. Open the Account Settings dialog by selecting Account settings or by going to File > Account Settings....

    Screenshot of the Account Settings window.

  2. From the All Accounts submenu, select + Add dropdown to add an account, and then select GitHub.

    Screenshot showing how to select and add a GitHub account.

  3. Select GitHub Enterprise on the Connect to GitHub dialog.

  1. Select the icon with your initials in the upper-right corner of the Visual Studio environment. Open the Account Settings dialog by selecting Account settings or by going to File > Account Settings....

    Screenshot of the Account Settings window.

  2. From the All Accounts submenu, select + Add dropdown to add an account, and then select GitHub.

    Screenshot showing how to select and add a GitHub account.

  3. Select GitHub Enterprise on the Connect to GitHub dialog.

Note

Ensure you enter your GitHub EMU account credentials (the username has an underscore followed by the company name) on this page.

Screenshot showing the GitHub sign in experience for the GitHub Enterprise Managed User account.

After you sign in, you'll get a success window in the browser, and you can return to Visual Studio.

Screenshot showing the sign-in success window in the browser.

Remove an account

To remove an account, select Remove for the account you want to remove from the All Accounts submenu in the Account Settings dialog.

  1. Select File > Account Settings....
  2. All Accounts lists all accounts signed into Visual Studio. Select Remove for the account you want to remove.
  3. Confirm the removal on the dialog that appears.

Remove an account

To remove an account:

  1. Select the icon with your profile name in the upper-right corner of your Visual Studio environment.

  2. Select Remove account for the account you want to remove.

    Screenshot of removing an account.

You can also use the Account Settings dialog to remove an account.

  1. Select File > Account Settings....

  2. All Accounts lists all accounts signed into Visual Studio. Select Remove for the account you want to remove.

  3. Confirm the removal on the dialog that appears.

    Screenshot of removing an account in Account Settings.

Troubleshooting sign in issues

If you're experiencing issues when adding or re-authenticating GitHub accounts, try the following steps:

HTTP Strict Transport Security (HSTS) issues

Verify that HTTP Strict Transport Security (HSTS) is not enabled for localhost on your system's default web browser:

  • On Microsoft Edge, you can type: edge://net-internals/#hsts and enter localhost under the Delete domain security policies section.
  • On Google Chrome, type: chrome://net-internals/#hsts and enter localhost under the Delete domain security policies section.

Run-as issues

Running Visual Studio using an account that doesn't match your signed-in Windows account, may cause issues when adding GitHub accounts to Visual Studio. You may encounter this issue when using 3rd party products that attempt to run Visual Studio elevated.

You can verify the user by following these steps:

  1. Open the Task Manager
  2. Navigate to the Details tab
  3. Search for the devenv.exe process
  4. Ensure the username for that process matches the signed in Windows Account

To fix this, run Visual Studio as the user you're signed into Windows with, and then add your GitHub account.

Note

Please report a problem if you're still experiencing sign in issues.