GitHub Copilot Completions Cheat Sheet
GitHub Copilot’s completions encompass key features, including Code Suggestions, Text Completion, and Code Referencing. Each section explains how these features work, their controls, best practices, and examples to help you maximize their utility.
Code Suggestions
Code Suggestions are the heart of GitHub Copilot. As you type in your Integrated Development Environment (IDE), Copilot offers intelligent code completions based on the context of your code, helping you write code faster and with fewer errors.
How It Works
- Copilot analyzes the context of your code, including functions, variables, and libraries, to provide relevant code suggestions.
-
You can also prompt Copilot with natural language comments (e.g., // function to reverse a string), and it will suggest corresponding code.
Key Controls & Behaviors
| Action |
Behavior |
| Accept Full Suggestion |
Press Tab (or configured key) to insert the suggestion. |
| Accept Partial Suggestion |
Accept individual words or lines using Tab or other IDE shortcuts. |
| Cycle Through Suggestions |
Use keyboard shortcuts (e.g., Option/Alt + ] or [) to cycle through alternate suggestions. |
| Open Suggestion Panel |
Use Ctrl + Enter (Windows) / Cmd + Shift + A (macOS) to view multiple suggestions. |
| Dismiss Suggestion |
Press Esc or continue typing to dismiss the suggestion. |
Supported Languages
- Python
- JavaScript/TypeScript
- Ruby
- Go
- C#
- C++
Public Code Matching & Policies
-
Copilot may suggest code that matches publicly available code. You can configure whether to allow or block these suggestions through GitHub settings.
-
For private repositories, suggestions are not based on your private code unless explicitly configured.
Best Practices
-
Providing detailed comments or method signatures helps guide Copilot in generating more accurate suggestions.
-
Always check the generated code for correctness, style, and security before using it.
-
To avoid suggestions that match public code, enable the setting to block them.
Text Completion
Text Completion helps you write and auto‑complete written content, such as pull request descriptions or issue comments, using the context of your project.
How It Works
-
PR Descriptions: As you write a pull request description, Copilot suggests ways to complete sentences based on the files changed, issues referenced, and the context of the PR.
-
Issue and Comment Generation: Copilot also helps generate text for issues or comments related to your code.
Limitations
-
Currently, text completion is only available for English content.
-
Public Preview: This feature is currently in public preview and may undergo changes over time.
-
Not Always Accurate: Text completion is most effective when starting fresh (e.g., new PRs) rather than editing pre‑existing descriptions.
Best Practices
-
Provide Clear Context: The more context you provide (e.g., file changes, referenced issues), the better the suggestions will be.
-
Review Suggestions: Always review the text to ensure it aligns with your style and organizational guidelines.
Code Referencing
Code Referencing identifies when Copilot suggests code that matches public code. This is useful for ensuring compliance with open-source licenses and understanding the origin of the proposed code.
How It Works
-
Public Code Matching: Copilot checks the suggestions it provides against publicly available code repositories on GitHub. If a match is found, Copilot delivers a link to the original code and its associated license.
-
Attribution: If a suggestion matches public code, Copilot includes the URL of the matched repository and the license type (e.g., MIT, GPL).
Policy & Settings
-
Enable/Disable Public Code Matching: You can configure GitHub Copilot to either allow or block suggestions that match public code. This setting helps ensure your project remains compliant with licensing requirements.
-
Audit Logs: If you enable code referencing, you can review logs to track the instances where public code is referenced.
Best Practices
-
Review Public Code Matches: When Copilot suggests public code, ensure it aligns with your project’s licensing requirements.
-
Attribution & License Review: When using public code, ensure that you provide proper attribution and verify the license is compatible with your project.
CONCLUSION
GitHub Copilot is a powerful tool that significantly enhances productivity by offering intelligent code suggestions, text completions, and code referencing. Analyzing the context of your code and providing context-aware suggestions enables developers to write code more efficiently and with fewer errors.
To get the most out of Copilot, it is essential to:
-
Use detailed comments and method signatures to guide the tool towards generating more accurate code completions.
-
Be vigilant in reviewing suggestions for correctness, style, and security, especially when dealing with public code matching.
-
Leverage text completion for generating pull request descriptions and comments, ensuring clear context is provided to maximize suggestion relevance.
-
Regularly review public code references to maintain compliance with open-source licensing requirements and ensure proper attribution.
While GitHub Copilot is an invaluable assistant for developers, it is crucial to review its suggestions and configurations (such as blocking public code matches when necessary) to ensure that they meet project requirements and adhere to best practices.
REFERENCES
https://docs.github.com/en/copilot/concepts/completions/code-suggestions
https://docs.github.com/en/copilot/concepts/completions/text-completion
https://docs.github.com/en/copilot/concepts/completions/code-referencing














