Skip to main content

通过 GHE.com 上的帐户使用 Copilot

更新开发环境,以访问 GHE.com 上帐户的 Copilot 计划。

To use Copilot in an IDE or the command line, you must authenticate to an account on that has a Copilot license.

If you receive access to Copilot through a managed user account owned by an enterprise on GHE.com, you may need to adjust some settings in your IDE before you can authenticate to your account.

Use the tabs at the top of this article to see instructions for your environment.

Authenticating from VS Code

  1. To open your VS Code settings, press Command+, (Mac) or Ctrl+, (Windows).

  2. In the search bar, search for enterprise.

  3. For the -enterprise: Uri setting, enter the URL where you access . For example: https://octocorp.ghe.com.

  4. In the VS Code settings, search for copilot.

  5. Under " > Copilot: Advanced," click Edit in settings.json.

  6. Inside the .copilot.advanced property, add "authProvider": "-enterprise". For example:

    JSON
    ".copilot.advanced": {
         "authProvider": "-enterprise"
    },
    
  7. Save the settings.json file.

  8. You will be shown a prompt asking you to sign in to use Copilot. Click Sign in to , then follow the prompts to authorize your account.

    If you don't see the prompt, try restarting VS Code.

If you ever need to switch to an account on .com, remove the authProvider setting from settings.json.

Authenticating from JetBrains IDEs

To authenticate to GHE.com in a JetBrains editor, you must install version 1.4.11 or later of the Copilot extension. You must then configure the extension to work with GHE.com.

  1. To open the editor preferences or settings dialog, press Command+, (Mac) or Ctrl+Alt+S (Windows).
  2. In the left sidebar, expand the "Languages & Frameworks" section, then click Copilot.
  3. In the "Authentication Provider" field, enter the hostname where you access . For example: octocorp.ghe.com.
  4. To save your changes, click OK.
  5. To sign in, open the Tools menu, then select Copilot > Login to . Follow the prompts to sign in.

If you ever need to switch to an account on .com, remove the value you entered in the "Authentication Provider" field.

Authenticating from Xcode

  1. Open the " Copilot for Xcode" application.
  2. Click the Advanced tab.
  3. In the "Auth provider URL" field, enter the URL where you access . For example: https://octocorp.ghe.com.
  4. Authorize the extension by following the instructions in Signing in to Copilot.

Authenticating from the command line

To use the gh-copilot extension for the CLI, you must:

  1. Download and install the extension. To do this, you must be authenticated to an account on .com. See Installing Copilot in the CLI.
  2. Authenticate to the account on GHE.com where you receive your Copilot license.

.com is the default destination of CLI requests. To use gh copilot, you must ensure requests are sent to GHE.com, where you receive your license. You have the following options:

  • Include the flag --hostname SUBDOMAIN.ghe.com in all gh copilot commands.
  • Set the GH_HOST environment variable to change the default host for all CLI commands.
  • Sign out of .com with gh auth logout. However, you will need to sign back in to get updates to gh-copilot.

For general information on using the CLI across platforms, see Using the CLI across platforms.

Authenticating from Visual Studio

To authenticate from Visual Studio, follow the steps in Add your accounts to your Visual Studio keychain on Microsoft Learn.

For the " Enterprise URL" field, enter the URL where you access . For example: https://octocorp.ghe.com.

Authenticating from Eclipse

  1. In the IDE, click Copilot to open the menu.
  2. Click Edit Preferences....
  3. In the Enterprise Authentication Endpoint field, enter the URL where you access . For example: https://octocorp.ghe.com.
  4. Click Apply.
  5. Open the Copilot menu again then click Sign In to .