All tutorials/3 min/Beginner

Copilot tutorial

How to Install GitHub Copilot CLI on Mac and Windows

Step-by-step guide to installing the GitHub Copilot CLI extension. Learn how to authenticate and run gh copilot suggest and explain in your terminal.

AI ToolsCLIBeginner
Interactive tutorial

Quick command sequence

$ gh extension install github/gh-copilot

/es/tutorials/install-github-copilot-cli-mac-windows

Interactive command lab

1/4

Step 1

Verify GitHub CLI

If you get 'command not found', install it first via Homebrew (`brew install gh`) or the Windows winget (`winget install --id GitHub.cli`).

Checkpoint

gh --version

zsh — tutorial-lab

Command tray

$ gh --version

gh version 2.45.0 (2024-03-04)

https://github.com/cli/cli/releases/tag/v2.45.0

Step-by-step instructions

  1. 1

    Step

    Verify GitHub CLI

    If you get 'command not found', install it first via Homebrew (`brew install gh`) or the Windows winget (`winget install --id GitHub.cli`).

    gh --version
  2. 2

    Step

    Authenticate with GitHub

    Ensure you log in with an account that has an active GitHub Copilot subscription.

    gh auth login
  3. 3

    Step

    Install the Copilot Extension

    This command downloads the Copilot binaries directly from GitHub's official extension registry.

    gh extension install github/gh-copilot
  4. 4

    Step

    Test Copilot

    You can use `gh copilot suggest` to write commands, or `gh copilot explain` to decipher complex terminal commands.

    gh copilot suggest "undo my last commit"

Why this matters

Memorizing complex bash commands, ffmpeg flags, or git rebases is tedious. The GitHub Copilot CLI brings the AI assistant you already use in VS Code directly into your terminal. Instead of switching to a browser to ask ChatGPT how to find and delete large files, you can just type `gh copilot suggest` and execute the result immediately.

Troubleshooting

  • **'gh: command not found':** The Copilot CLI is not a standalone tool. It is an extension for the GitHub CLI. You must install the base GitHub CLI first via Homebrew (`brew install gh`), apt, or winget.
  • **Authentication errors:** The extension will fail to run if your GitHub account does not have an active Copilot Individual, Business, or Enterprise subscription.
  • **Command too long to type:** Typing `gh copilot suggest` every time is slow. You can set up terminal aliases. Run `gh copilot --help` and follow the instructions to set up aliases like `??` for suggest and `?!` for explain.

FAQ

Do I need a paid GitHub Copilot subscription?

Yes. The CLI extension uses the same backend API as the VS Code extension and requires an active Copilot subscription attached to your GitHub account.

Why do I get 'extension not found'?

Ensure you type the command exactly as `gh extension install github/gh-copilot`. The 'github/' prefix specifies the official repository.

Can it execute the commands automatically?

Yes. When you use `gh copilot suggest`, it will present you with an interactive menu where you can choose to 'Execute command' directly, or revise it.

How do I update the gh copilot extension?

You can update all your GitHub CLI extensions, including Copilot, by running the command `gh extension upgrade --all`.

Is the GitHub Copilot CLI the same as Claude Code or Codex CLI?

No. GitHub Copilot CLI focuses heavily on single-command generation and explanation. Tools like Claude Code are full agentic systems designed to read entire codebases and modify multiple files autonomously.

Related tutorials