GitHub Copilot CLI Cheatsheet
GitHub Copilot CLI is GitHub's AI terminal assistant, available as a gh extension that provides command suggestions (suggest) and command explanations (explain) to help you work more efficiently in the terminal.
Overview
GitHub Copilot CLI brings AI assistance to your terminal, letting you describe tasks in natural language to get command suggestions or explanations. Available as a gh extension, it integrates deeply with the GitHub ecosystem.
Quick Start
``bash
# Install GitHub CLI (if not installed)
# macOS
brew install gh
# Ubuntu/Debian
sudo apt install gh
# Install Copilot CLI extension gh extension install github/gh-copilot
# Login to GitHub gh auth login --web
# Use the Suggest feature gh copilot suggest "Find all large log files" ``
Refer to the command table below for detailed usage.
Installation & Setup
Copilot CLI is distributed as a gh extension. Before installing, ensure you have GitHub CLI (>= 2.0.0) installed and are logged into a GitHub account. Supports macOS, Linux, and Windows.
Command Suggest
Describe what you want to accomplish in natural language, and Copilot CLI recommends terminal commands. Supports interactive selection and direct execution. The ghcs alias provides faster access.
Command Explain
Paste or type a terminal command, and Copilot CLI explains what it does, what each flag means, and the overall effect — helping you understand complex commands or learn new tools.
Configuration & Aliases
Manage settings with gh copilot config, and set up shell aliases for bash, zsh, or PowerShell with gh copilot alias. Supports GH_HOST env var and --hostname flag for GitHub Enterprise instances.
Install & Setup(6)
| Command | Level | ||
|---|---|---|---|
gh extension installInstall Copilot CLI gh extension | Basic | gh extension install github/gh-copilot | |
gh auth login --webLogin to GitHub account via browser | Basic | gh auth login --web | |
gh auth loginLogin to GitHub account via token | Basic | gh auth login --with-token < token.txt | |
gh copilot --helpView Copilot CLI help information | Basic | gh copilot --help | |
gh extension upgradeUpgrade Copilot CLI extension to latest | Basic | gh extension upgrade gh-copilot | |
gh extension removeRemove Copilot CLI extension | Basic | gh extension remove gh-copilot |
Command Suggest(6)
| Command | Level | ||
|---|---|---|---|
gh copilot suggestSuggest terminal commands based on natural language | Basic | gh copilot suggest 'Find all files larger than 100MB' | |
gh copilot suggest -tSpecify command type (shell/gh/git) | Intermediate | gh copilot suggest -t gh 'List all open issues' | |
gh copilot suggest -t shellGet general shell command suggestions | Basic | gh copilot suggest -t shell 'Monitor disk space' | |
gh copilot suggest -t gitGet git command suggestions | Basic | gh copilot suggest -t git 'Undo last commit keeping changes' | |
gh copilot suggest -t ghGet GitHub CLI command suggestions | Basic | gh copilot suggest -t gh 'Create a new release' | |
Execute suggested commandSelect to execute the suggested command | Intermediate | gh copilot suggest 'Remove temp files' -> Select 'Execute' |
Command Explain(3)
| Command | Level | ||
|---|---|---|---|
gh copilot explainExplain what a terminal command and its flags do | Basic | gh copilot explain 'git rebase -i HEAD~3' | |
gh copilot explain complexExplain each part of a complex piped command | Expert | gh copilot explain 'ps aux | grep python | awk "{print \$2}" | xargs kill -9' | |
gh copilot explain --fullFull explanation of every option and argument | Intermediate | gh copilot explain --full 'docker run -d --name web -p 80:80 nginx' |
Configuration(6)
| Command | Level | ||
|---|---|---|---|
gh copilot configView or modify Copilot CLI configuration | Intermediate | gh copilot config | |
gh copilot config setSet a configuration value | Intermediate | gh copilot config set editor vim | |
gh copilot config getGet a specific configuration value | Intermediate | gh copilot config get editor | |
--hostnameSpecify GitHub Enterprise Server hostname | Intermediate | gh copilot suggest --hostname github.mycompany.com 'List repos' | |
GH_HOSTEnvironment variable for GitHub Enterprise hostname | Intermediate | export GH_HOST=github.mycompany.com | |
gh copilot versionCheck Copilot CLI version | Basic | gh copilot version |
Aliases(6)
| Command | Level | ||
|---|---|---|---|
gh copilot aliasSet up shell aliases (interactive wizard) | Basic | gh copilot alias | |
gh copilot alias bashSet up aliases for Bash (ghcs/ghce) | Basic | gh copilot alias bash >> ~/.bashrc | |
gh copilot alias zshSet up aliases for Zsh (ghcs/ghce) | Basic | gh copilot alias zsh >> ~/.zshrc | |
gh copilot alias pwshSet up aliases for PowerShell (ghcs/ghce) | Basic | gh copilot alias pwsh >> $PROFILE | |
ghcsShortcut alias for gh copilot suggest | Basic | ghcs 'Kill process on port 3000' | |
ghceShortcut alias for gh copilot explain | Basic | ghce 'lsof -i :3000' |