Note
GitHub Copilot Chat in GitHub is currently in versão prévia pública and is subject to change.
In this guide, you’ll learn how to use Copilot Chat in GitHub to understand a repository’s purpose, examine files, and dive into specific lines of code. By following these steps, you’ll gain insights into any project faster—making onboarding, code review, and project exploration easier and more efficient.
Prerequisites
You'll need a GitHub Copilot subscription. For more information, see "O que é o GitHub Copilot?."
Understanding a repository
When you’re new to a project, it can be challenging to understand the purpose of a repository and its files. Copilot can help you quickly understand the purpose of a repository, for example, by providing a summary of the repository’s README file.
-
On the GitHub website, go to the repository you want to chat about.
-
Click the GitHub Copilot icon at the top right of the page.
-
The heading at the top of the chat panel should read "Chatting about" followed by the name of the current repository.
If the wrong repository name is displayed, because you were previously chatting about another repository, click All repositories then choose the repository you want to chat about.
-
In the "Ask Copilot" box, at the bottom of the chat panel, type "Summarize the purpose of this repository based on the README" and press Enter. Copilot replies in the chat panel.
You can also use Copilot to understand the roles of different folders and files within the repository. For example, you can ask Copilot to summarize the contents of a specific file, or to explain the purpose of a specific folder.
Exploring files and code
When you’re exploring a project, you might want to understand the contents of a specific file. Copilot can help you quickly understand the purpose of a file, for example, by providing a summary of the file’s contents. You can also ask Copilot to explain specific lines of code within a file.
-
On GitHub, navigate to a repository and open a file.
-
Do one of the following:
-
To ask a question about the entire file, click the Copilot icon () at the top right of the file view.
-
To ask a question about specific lines within the file:
- Click the line number for the first line you want to ask about, hold down Shift, then click the line number for the last line you want to select.
- To ask your own question about the selected lines, click the Copilot icon () to the right of your selection, then type your question in the GitHub Copilot Chat panel.
- To ask a predefined question, click the drop-down menu beside the Copilot icon, then choose one of the options.
-
-
If you clicked the Copilot icon, type a question in the "Ask Copilot" box at the bottom of the chat panel and press Enter.
For example, if you are asking about the entire file, you could enter:
Explain this file.
How could I improve this code?
How can I test this script?
If you are asking about specific lines, you could enter:
Explain the function at the selected lines.
How could I improve this class?
Add error handling to this code.
Write a unit test for this method.
Copilot responds to your request in the panel.
-
Opcionalmente, clique em na caixa de texto para impedir que o Copilot continue sua resposta.
-
You can continue the conversation by asking a follow-up question. For example, you could type "tell me more" to get Copilot to expand on its last comment.
Next steps
Now that you know how to use Copilot to explore projects, you can use it to help you understand any repository, file, or line of code on GitHub.