Copilot moves into the terminal
Command-line work is a daily reality for most developers, but it rarely comes without friction. Whether it is remembering the exact Git syntax, untangling a merge conflict, or checking permissions, the terminal often interrupts your flow. You could open a browser and hunt for the right command, but that breaks focus and does not always yield a precise answer. GitHub Copilot in the CLI aims to remove that obstacle by letting you ask questions or request suitable commands conversationally, directly in your terminal.
Copilot in the CLI is an extension for the GitHub CLI and supports Windows, macOS, and Linux. To use it, you need the GitHub CLI installed and an active GitHub Copilot subscription. For users on Business or Enterprise plans, an organization or enterprise policy must also permit “Copilot in the CLI”:

Those policy settings are managed under your profile icon on github.com → Settings → Copilot. Before installing the extension, authenticate with gh auth login. Then install it with:
gh extension install github/gh-copilot
Once installed, the extension is available through gh copilot, and you can explore its usage at any time with gh copilot --help.
Explaining tricky concepts
The explain feature is useful when you need to understand a concept or decode a command, rather than execute one. Typing gh copilot explain followed by a natural-language question starts the conversation. For instance, if you receive a cryptic script from a teammate such as npx sirv-cli ., you can ask Copilot to break down what it does. It is also handy for broader questions like how to roll back a commit or what distinguishes Git from GitHub.
Getting command suggestions
When explain is not enough and you need an executable command, switch to gh copilot suggest. Copilot first asks what kind of command you want, with three choices:
![What kind of command can I help you with? [use arrows to move, type to filter] generic shell command, gh command, git command](https://github.blog/wp-content/uploads/2024/09/Command-type.png?w=1024&resize=1024%2C120)
- generic shell command
- gh command (GitHub CLI)
- git command
Selecting the correct category lets Copilot tailor its answer. After each suggestion, you can ask for more explanation, execute the command, copy it, revise the request, or exit.
Generic shell commands
For terminal tasks that have nothing to do with Git or GitHub, pick generic shell command. As an example, you can ask Copilot how to kill a process listening on a specific port. Copilot will ask follow-up questions to refine the suggestion and then produce a command you can run immediately.
Git commands
Mistakes and unfamiliar operations happen with Git more often than most developers would like. Choose git command to get suggestions for these cases.
Say you want to confirm the current branch before committing — Copilot can suggest the right git command and explain it. Similarly, if you have accidentally committed new changes to the main branch and want them on a new branch, Copilot can step you through the reset and branch creation process. It will also tell you how to amend the message of your previous commit.
Do keep in mind that suggestions are not always perfect at the first attempt. If a response is too long, does not fit your exact scenario, or the original question was ambiguous, you can revise the prompt and ask again. In one example, the suggestion leaned toward creating a new branch first, then resetting the old one — a sequence that may differ from a shorter phrasing of the same question.
GitHub CLI commands
For operations involving GitHub — not just Git — select gh command so Copilot knows to look for GitHub CLI syntax. This narrows the search down to gh-specific functionality.
For instance, you can ask how to view the diff of a pull request, and Copilot will produce a command that includes the pull request number. Asking whether any pull requests or issues are assigned to you in the current repository will yield an answer — possibly a reassuring one. You can also combine Git and GitHub steps: commit all changes to a new branch, switch to it, and then create a pull request.
Here, Copilot might return a fully qualified command like gh pr create --base --head --title “” --body <"pull_request_body">, but you are not obliged to run it verbatim. Checking the output matters. If the suggested command injects more flags than you need, a plain gh pr create may be the better path — it guides you through an interactive prompt. The lesson carries over from Git examples: review before you execute.
Aliases for faster prompts
Typing gh copilot suggest every time is tedious, so the extension ships prebuilt aliases. ghcs maps to “Copilot suggest,” and the ghce alias covers “Copilot explain.” The --target flag (short: -t) further streamlines things by letting you skip the question about command type — you can set it directly to shell, gh, or git. The configuration for these aliases differs by operating system; the GitHub Copilot docs and linked videos cover the setup for your environment.
Writing Effective Prompts
Prompt quality matters more with GitHub Copilot CLI than it does in the editor. In the editor, Copilot has rich context from the surrounding code; in the CLI, it has far less to work with. Your prompt needs to be concise and specific enough to capture exactly what you're asking. If the first answer misses the mark, revise and re-ask.
For guidance on crafting better prompts, refer to the GitHub guide on prompt engineering.
Trying It Yourself
That covers the essentials of using Copilot from the command line. You can now work through the examples in this guide on your own. If you do, share your results in the community discussion—it's a good way to compare the kinds of responses Copilot generates for different prompts and learn from each other's approaches.



