About GitHub Copilot Chat and Visual Studio Code
GitHub Copilot Chat 是一个聊天界面,可让你直接在受支持的 IDE 中询问编码相关问题并接收答案。 Copilot Chat 可帮助你完成各种编码相关任务,例如提供代码建议、提供代码片段功能和用途的自然语言说明、为代码生成单元测试,以及为代码中的 bug 建议修复。 有关详细信息,请参阅“关于 GitHub Copilot Chat”。
Prerequisites
-
若要使用 GitHub Copilot Chat,必须拥有有效的 GitHub Copilot 订阅。 有关详细信息,请参阅“关于 GitHub Copilot 的计费”。
-
To use GitHub Copilot Chat in Visual Studio Code, you must have the latest version of Visual Studio Code installed. For more information, see the Visual Studio Code download page.
-
To use GitHub Copilot Chat in Visual Studio Code, you must be signed into Visual Studio Code with the same GitHub ID that has access to GitHub Copilot.
启用或禁用 GitHub Copilot Chat
注意:**** 如果你有 GitHub Copilot Individual 订阅,则将自动获得 GitHub Copilot Chat beta 版的访问权限。
GitHub Copilot Chat 公共 beta 版已向具有有效 GitHub Copilot Business 许可证的所有组织和企业开放。 可以在 GitHub Copilot Business 设置页面中为你的组织或企业启用或禁用 GitHub Copilot Chat。
在组织级别启用或禁用 GitHub Copilot Chat
-
在 GitHub.com 的右上角,选择个人资料照片,然后单击 “你的组织”****。
-
在组织旁边,单击“设置”。
-
在边栏的“代码规划和自动化”部分中,单击“ Copilot”,然后单击“策略” 。
-
在“GitHub Copilot Chat beta 版”的右侧,选择下拉菜单,然后单击“已启用”或“已禁用”。************
在企业级别启用或禁用 GitHub Copilot Chat
- 在企业帐户边栏中,单击“ 策略”。 1. 在“ 策略”下,单击“Copilot”。
- 在“GitHub Copilot Chat beta 版”的右侧,选择下拉菜单,然后选择相应的选项。
- 单击“允许”,为企业下的所有组织启用 GitHub Copilot Chat beta 版。
- 单击“阻止”,为企业下的所有组织禁用 GitHub Copilot Chat beta 版。
- 单击“无策略”,允许企业下的每个组织设置自己的策略。
Installing the GitHub Copilot Chat extension in Visual Studio Code
To use GitHub Copilot Chat, you must first install the GitHub Copilot Chat extension for Visual Studio Code.
-
In Visual Studio Code, open the Extensions view by clicking the Extensions icon in the activity bar on the left side of the Visual Studio Code window.
-
In the "Search Extensions in Marketplace" search box, search for the
GitHub Copilot Chat
extension, then click Install. -
In the Visual Studio Code window, click Reload required to update Visual Studio Code.
-
If you are prompted to sign in by a toast notification in the bottom right corner of Visual Studio Code, click Sign in to GitHub and sign in with the same GitHub ID that has been granted access to the GitHub Copilot Chat limited public beta.
-
Follow the prompts in Visual Studio Code and on GitHub in your browser to complete the sign in and authentication process.
-
To confirm that GitHub Copilot Chat has been successfully installed, in the activity bar on the left side of the Visual Studio Code window, click the GitHub Copilot Chat icon to open the GitHub Copilot Chat chat window.
Note: If you experience authentication issues after installing the extension, see "排查 GitHub Copilot Chat 的问题."
Asking your first question
GitHub Copilot Chat 旨在以自然语言专门回答你询问的编码相关问题。 例如,可以要求 GitHub Copilot Chat 来帮助你编写返回两个数字之和的函数。
-
In the Visual Studio Code activity bar, click the GitHub Copilot Chat icon to open the GitHub Copilot Chat chat window.
-
At the bottom of the GitHub Copilot Chat window, in the Ask Copilot a question or type
/
for topics text box, type a coding related question, then press Enter. For example, type "How do I write a function that returns the sum of two numbers?". -
GitHub Copilot Chat will process your question and provide an answer, with code suggestions when appropriate, in the chat window.
If your question is outside the scope of GitHub Copilot Chat, it will tell you and may suggest an alternative question to ask.
-
Optionally, if GitHub Copilot Chat suggests a follow-up question above the Ask Copilot a question or type
/
for topics text box, click the follow-up question to ask it.
Using code suggestions from GitHub Copilot Chat
When GitHub Copilot Chat provides code suggestions, you have a few options for how to use them.
-
In the GitHub Copilot Chat window, to show the options for a code suggestion, hover over the suggestion.
-
Choose one of the options for using the code suggestion.
- To copy the code suggestion to your clipboard, click the Copy icon.
- To insert the code suggestion into your code at the current location of your cursor, click the Insert at Cursor icon.
- To view additional options, click the ... icon.
- To create a new file and insert the suggestion into it, click Insert Into New File.
- To run the code suggestion in the Visual Studio Code terminal, click Run in Terminal.
Asking GitHub Copilot Chat questions about your code
GitHub Copilot Chat can provide answers and support with a wide range of coding related topics.
- In Visual Studio Code, open the file you want GitHub Copilot Chat to help you with.
- Ask GitHub Copilot Chat a question about the file you have open. For example:
- To generate a description of the file's purpose, ask a question like,
What does this file do?
. - To generate a unit test for the file, type a request like,
Write a unit test for this file
. Alternatively, highlight the code you want to generate a unit test for, then ask a question like,Write a unit test for this code
. - To generate a fix for a bug in the file, type a request like,
Fix this bug
.
- To generate a description of the file's purpose, ask a question like,
Sharing feedback about GitHub Copilot Chat
To share feedback about GitHub Copilot Chat, you can use the share feedback button in the GitHub Copilot Chat window.
- Scroll to the top of the GitHub Copilot Chat window.
- Click the share feedback button.
- In your browser, in the vscode-copilot-release repository, create a new issue or open the GitHub Copilot community discussion.
- To open an issue to report a bug, next to Bug report for GitHub Copilot Chat, click Get started.
- To open an issue to request a feature, next to Feature request for GitHub Copilot Chat, click Get started.
- To report a security vulnerability, next to Report a security vulnerability, click View policy.
- To ask a question in a discussion, next to Questions, click Open.
Further reading
About GitHub Copilot Chat and Visual Studio
GitHub Copilot Chat 是一个聊天界面,可让你直接在受支持的 IDE 中询问编码相关问题并接收答案。 Copilot Chat 可帮助你完成各种编码相关任务,例如提供代码建议、提供代码片段功能和用途的自然语言说明、为代码生成单元测试,以及为代码中的 bug 建议修复。 有关详细信息,请参阅“关于 GitHub Copilot Chat”。
Prerequisites
-
若要使用 GitHub Copilot Chat,必须拥有有效的 GitHub Copilot 订阅。 有关详细信息,请参阅“关于 GitHub Copilot 的计费”。
-
To use GitHub Copilot Chat with Visual Studio, you must be running Visual Studio 2022 version 17.6 or higher. For more information, see the Visual Studio IDE documentation.
-
To use GitHub Copilot Chat with Visual Studio, you must be signed into Visual Studio with the same GitHub ID that has access to GitHub Copilot.
启用或禁用 GitHub Copilot Chat
注意:**** 如果你有 GitHub Copilot Individual 订阅,则将自动获得 GitHub Copilot Chat beta 版的访问权限。
GitHub Copilot Chat 公共 beta 版已向具有有效 GitHub Copilot Business 许可证的所有组织和企业开放。 可以在 GitHub Copilot Business 设置页面中为你的组织或企业启用或禁用 GitHub Copilot Chat。
在组织级别启用或禁用 GitHub Copilot Chat
-
在 GitHub.com 的右上角,选择个人资料照片,然后单击 “你的组织”****。
-
在组织旁边,单击“设置”。
-
在边栏的“代码规划和自动化”部分中,单击“ Copilot”,然后单击“策略” 。
-
在“GitHub Copilot Chat beta 版”的右侧,选择下拉菜单,然后单击“已启用”或“已禁用”。************
在企业级别启用或禁用 GitHub Copilot Chat
- 在企业帐户边栏中,单击“ 策略”。 1. 在“ 策略”下,单击“Copilot”。
- 在“GitHub Copilot Chat beta 版”的右侧,选择下拉菜单,然后选择相应的选项。
- 单击“允许”,为企业下的所有组织启用 GitHub Copilot Chat beta 版。
- 单击“阻止”,为企业下的所有组织禁用 GitHub Copilot Chat beta 版。
- 单击“无策略”,允许企业下的每个组织设置自己的策略。
Installing the GitHub Copilot Chat extension in Visual Studio
To use GitHub Copilot Chat with Visual Studio, you must install the Visual Studio extension.
-
在 Visual Studio 菜单栏中,单击“扩展”,然后单击“管理扩展” 。
-
In the "Manage Extensions" window, click Visual Studio Marketplace, search for "GitHub Copilot Chat", then click Download.
-
关闭“管理扩展”窗口,然后退出并重新启动 Visual Studio。
Note: If you experience authentication issues after installing the extension, see "排查 GitHub Copilot Chat 的问题."
Asking your first question
GitHub Copilot Chat 旨在以自然语言专门回答你询问的编码相关问题。 例如,可以要求 GitHub Copilot Chat 来帮助你编写返回两个数字之和的函数。
-
In the Visual Studio menu bar, to launch GitHub Copilot Chat, click View, then click GitHub Copilot Chat.
-
At the bottom of the Copilot Chat window, in the Ask Copilot text box, type a coding related question, then press Enter. For example, type "How do I write a function that returns the sum of two numbers?".
Note: If your question is outside the scope of GitHub Copilot Chat, it will tell you and may suggest an alternative question to ask.
-
If Copilot Chat offers a code suggestion that you want to use, click the Copy icon to copy the code suggestion to your clipboard.
-
Optionally, if GitHub Copilot Chat suggests a follow-up question under your last answer, click the follow-up question to ask it.
Asking GitHub Copilot Chat questions about your code
GitHub Copilot Chat can provide answers and support with a wide range of coding related topics.
- In Visual Studio, open the file you want GitHub Copilot Chat to help you with.
- Ask GitHub Copilot Chat a question about the file you have open. For example:
- To generate a description of the file's purpose, ask a question like,
What does this file do?
. - To generate a unit test for the file, type a request like,
Write a unit test for this file
. Alternatively, highlight the code you want to generate a unit test for, then ask a question like,Write a unit test for this code
. - To generate a fix for a bug in the file, type a request like,
Fix this bug
.
- To generate a description of the file's purpose, ask a question like,
Sharing feedback about GitHub Copilot Chat
To share feedback about GitHub Copilot Chat, you can use the Send feedback button in Visual Studio. For more information on providing feedback for Visual Studio, see the Visual Studio Feedback documentation.
-
In the top right corner of the Visual Studio window, click the Send feedback button.
-
Choose the option that best describes your feedback.
- To report a bug, click Report a problem.
- To request a feature, click Suggest a feature.
Further reading
About GitHub Copilot Chat and JetBrains
GitHub Copilot Chat 是一个聊天界面,可让你直接在受支持的 IDE 中询问编码相关问题并接收答案。 Copilot Chat 可帮助你完成各种编码相关任务,例如提供代码建议、提供代码片段功能和用途的自然语言说明、为代码生成单元测试,以及为代码中的 bug 建议修复。 有关详细信息,请参阅“关于 GitHub Copilot Chat”。
Prerequisites
-
若要使用 GitHub Copilot Chat,必须拥有有效的 GitHub Copilot 订阅。 有关详细信息,请参阅“关于 GitHub Copilot 的计费”。
-
To use the GitHub Copilot Chat beta in JetBrains, you must have a compatible JetBrains IDE installed. Copilot Chat is compatible with the following IDEs:
- IntelliJ IDEA (Ultimate, Community, Educational)
- Android Studio
- AppCode
- CLion
- DataGrip
- DataSpell
- GoLand
- MPS
- PhpStorm
- PyCharm (Professional, Community, Educational)
- Rider
- RubyMine
- RustRover
- WebStorm
For more information, see the JetBrains IDEs tool finder.
Enabling or disabling GitHub Copilot Chat
Note: If you have a GitHub Copilot Individual subscription, you can join the waitlist. You will be notified by email when you have been grated access. Joining the waitlist does not guarantee you access.
The GitHub Copilot Chat public beta is available to all organizations and enterprises that have an active GitHub Copilot Business license. You can enable or disable GitHub Copilot Chat for your organization or enterprise in the GitHub Copilot Business settings page.
Enabling or disabling GitHub Copilot Chat at the organization level
-
在 GitHub.com 的右上角,选择个人资料照片,然后单击 “你的组织”****。
-
在组织旁边,单击“设置”。
-
In the "Code planning, and automation" section of the sidebar, click Copilot, and then click Policies.
-
To the right of GitHub Copilot Chat Beta, select the dropdown menu, and then click Enabled or Disabled.
Enabling or disabling GitHub Copilot Chat at the enterprise level
- 在企业帐户边栏中,单击“ 策略”。
- 在“ 策略”下,单击“Copilot”。
- To the right of GitHub Copilot Chat Beta, select the dropdown menu, and then choose the appropriate option.
- Click Allowed to enable the GitHub Copilot Chat beta for all organizations under your enterprise.
- Click Blocked to disable the GitHub Copilot Chat beta for all organizations under your enterprise.
- Click No policy to allow each organization under your enterprise to set their own policy.
Installing or updating the GitHub Copilot plugin in JetBrains
To use the GitHub Copilot Chat beta in a JetBrains IDE, you must install or update the GitHub Copilot plugin. If you have not yet installed the GitHub Copilot plugin, follow the steps in "Installing the GitHub Copilot plugin in your JetBrains IDE." If you have already installed the GitHub Copilot plugin, follow the steps in "Updating the GitHub Copilot plugin in JetBrains."
The following procedures will guide you through installing or updating the GitHub Copilot plugin in IntelliJ IDEA. Steps to install the plugin in another supported IDE may differ.
Installing the GitHub Copilot plugin in your JetBrains IDE
To use GitHub Copilot in a JetBrains IDE, you must install the GitHub Copilot plugin.
-
In your JetBrains IDE, under the File menu for Windows or under the name of your IDE for Mac (for example, PyCharm or IntelliJ), click Settings for Windows or Preferences for Mac.
-
In the left-side menu of the Settings/Preferences dialog box, click Plugins.
-
At the top of the Settings/Preferences dialog box, click Marketplace. In the search bar, search for GitHub Copilot, then click Install.
-
After GitHub Copilot is installed, click Restart IDE.
-
After your JetBrains IDE has restarted, click the Tools menu. Click GitHub Copilot, then click Login to GitHub.
-
In the "Sign in to GitHub" dialog box, to copy the device code and open the device activation window, click Copy and Open.
-
A device activation window will open in your browser. Paste the device code, then click Continue.
-
GitHub will request the necessary permissions for GitHub Copilot. To approve these permissions, click Authorize GitHub Copilot Plugin.
-
After the permissions have been approved, your JetBrains IDE will show a confirmation. To begin using GitHub Copilot, click OK.
Updating the GitHub Copilot plugin in JetBrains
- In your JetBrains IDE, under the File menu for Windows or under the name of your IDE for Mac (for example, PyCharm or IntelliJ), click Settings for Windows or Preferences for Mac.
- In the left-side menu of the Settings/Preferences dialog box, click Plugins.
- At the top of the Settings/Preferences dialog box, click Installed. In the search bar, search for GitHub Copilot, then click Update.
- After GitHub Copilot is updated, quit and relaunch your JetBrains IDE.
Asking your first question
GitHub Copilot Chat 旨在以自然语言专门回答你询问的编码相关问题。 例如,可以要求 GitHub Copilot Chat 来帮助你编写返回两个数字之和的函数。
-
At the right side of the JetBrains IDE window, click the GitHub Copilot Chat icon to open the GitHub Copilot Chat window.
-
At the bottom of the GitHub Copilot Chat window, in the Ask Copilot a question or type
/
for commands text box, type a coding related question, then press Enter. For example, type "How do I write a function that returns the sum of two numbers?". -
GitHub Copilot Chat will process your question and provide an answer, with code suggestions when appropriate, in the chat window.
If your question is outside the scope of GitHub Copilot Chat, it will tell you and may suggest an alternative question to ask.
-
Optionally, if GitHub Copilot Chat suggests a follow-up question above the Ask Copilot a question or type
/
for commands text box, click the follow-up question to ask it.
Asking GitHub Copilot Chat questions about your code
GitHub Copilot Chat can provide answers and support with a wide range of coding-related topics.
- In your JetBrains IDE, open the file you want GitHub Copilot Chat to help you with.
- Ask GitHub Copilot Chat a question about the file you have open. For example:
- To generate a description of the file's purpose, ask a question like,
What does this file do?
. - To generate a unit test for the file, type a request like,
Write a unit test for this file
. Alternatively, highlight the code you want to generate a unit test for, then ask a question like,Write a unit test for this code
. - To generate a fix for a bug in the file, type a request like,
Fix this bug
.
- To generate a description of the file's purpose, ask a question like,
Sharing feedback about GitHub Copilot Chat
To share feedback about GitHub Copilot Chat, you can use the share feedback link in JetBrains.
-
At the right side of the JetBrains IDE window, click the GitHub Copilot Chat icon to open the GitHub Copilot Chat window.
-
At the top of the GitHub Copilot Chat window, click the share feedback link.