Using GitHub Copilot in the command line
You can use Copilot with the GitHub CLI to get suggestions and explanations for the command line.
In this article
Prerequisites
- Access to GitHub Copilot. SeeWhat is GitHub Copilot?.
- GitHub CLI installed. For installation instructions for GitHub CLI, see theGitHub CLI repository.
- Copilot in the CLI extension installed. SeeInstalling GitHub Copilot in the CLI.
If you have access to GitHub Copilot via your organization or enterprise, you cannot use Copilot in the CLI if your organization owner or enterprise administrator has disabled Copilot in the CLI. SeeManaging policies and features for Copilot in your organization.
Getting command explanations
To ask Copilot in the CLI to explain a command, rungh copilot explain
followed by the command that you want explained. For example:
gh copilot explain "sudo apt-get"
gh copilot explain "sudo apt-get"
Getting command suggestions
To ask Copilot in the CLI to suggest a command, rungh copilot suggest
followed by the command that you want. For example:
gh copilot suggest "Undo the last commit"
gh copilot suggest "Undo the last commit"
Copilot in the CLI will start an interactive session to get more information about what you want.
If you choose theExecute command option after Copilot in the CLI suggests a command, Copilot in the CLI will copy the command to your clipboard and exit the interactive session. Then you can manually paste the command into your CLI.
If you want Copilot in the CLI to be able to execute commands on your behalf, you must set up theghcs
alias. SeeCustomizing GitHub Copilot in the CLI.
Sharing feedback
To send feedback to GitHub about the quality of a suggestion, select theRate response option in Copilot in the CLI.
You can also open an issue in theCopilot in the CLI extension repository.