Installation Beginner

This guide walks you through installing GitHub Copilot CLI from scratch. You will install the GitHub CLI, add the Copilot extension, authenticate with your GitHub account, and verify everything is working.

Prerequisites

Before you begin, make sure you have:

Requirements Checklist:
  • A GitHub account with an active Copilot subscription
  • Internet connection for downloading tools and API access
  • Administrator/sudo access on your machine (for installing packages)

Step 1: Install GitHub CLI

GitHub Copilot CLI is an extension for the GitHub CLI (gh). You need to install gh first.

macOS

Terminal
# Using Homebrew (recommended)
$ brew install gh

# Or using MacPorts
$ sudo port install gh

# Or download from https://cli.github.com

Linux

Terminal
# Ubuntu / Debian
$ sudo apt install gh

# Fedora / RHEL
$ sudo dnf install gh

# Arch Linux
$ sudo pacman -S github-cli

# Or using conda-forge
$ conda install -c conda-forge gh

Windows

PowerShell
# Using winget (recommended)
$ winget install --id GitHub.cli

# Using Chocolatey
$ choco install gh

# Using Scoop
$ scoop install gh

# Or download the MSI from https://cli.github.com

Verify the installation:

Terminal
$ gh --version
# gh version 2.62.0 (2024-12-05)
Version Requirement: You need GitHub CLI version 2.40.0 or later. If your version is older, update it using the same package manager you used to install it (e.g., brew upgrade gh).

Step 2: Authenticate with GitHub

Before installing the Copilot extension, you need to authenticate with your GitHub account:

Terminal
$ gh auth login

# Follow the prompts:
# ? What account do you want to log into? GitHub.com
# ? What is your preferred protocol for Git operations? HTTPS
# ? Authenticate Git with your GitHub credentials? Yes
# ? How would you like to authenticate GitHub CLI? Login with a web browser
# 
# ! First copy your one-time code: XXXX-XXXX
# Press Enter to open github.com in your browser...

Verify your authentication:

Terminal
$ gh auth status
# github.com
#   Logged in to github.com as your-username
#   Token: gho_************************************
#   Token scopes: 'gist', 'read:org', 'repo', 'workflow'

Step 3: Install the Copilot CLI Extension

Now install the GitHub Copilot CLI extension:

Terminal
$ gh extension install github/gh-copilot

# You should see:
# Installed extension github/gh-copilot

If you already have it installed and want to update:

Terminal
# Update the Copilot extension
$ gh extension upgrade gh-copilot

# Or update all extensions at once
$ gh extension upgrade --all

Step 4: Verify Installation

Confirm everything is working by running a quick test:

Terminal
# Check that the extension is listed
$ gh extension list
# gh copilot  github/gh-copilot  v1.0.5

# Run a quick test
$ gh copilot --help
# Your AI command line copilot.
# 
# Usage:
#   copilot [command]
# 
# Available Commands:
#   explain     Explain a command
#   suggest     Suggest a command

# Try a suggestion
$ gh copilot suggest "list files in current directory"
First Run: The first time you use gh copilot, you may be asked to accept the GitHub Copilot CLI terms of use. Follow the prompts to agree and continue.

Troubleshooting

"gh: command not found"

Problem: The gh command is not recognized after installation.

Solution: Restart your terminal, or add the GitHub CLI to your PATH. On macOS with Homebrew, run brew link gh. On Windows, ensure the installer added it to your system PATH.

"extension already installed"

If you see this error, the extension is already present. Update it instead:

Terminal
$ gh extension upgrade gh-copilot

"Your account does not have Copilot access"

Problem: Your GitHub account does not have an active Copilot subscription.

Solution: Visit github.com/settings/copilot to check your subscription status. If you are part of an organization, ask your admin to enable Copilot for your account.

"authentication required"

If you see authentication errors, re-authenticate:

Terminal
# Re-authenticate
$ gh auth refresh

# Or log out and log back in
$ gh auth logout
$ gh auth login

Proxy or Firewall Issues

If you are behind a corporate proxy, you may need to configure proxy settings:

Terminal
# Set HTTP proxy
$ export HTTP_PROXY="http://proxy.example.com:8080"
$ export HTTPS_PROXY="http://proxy.example.com:8080"

Installation Checklist

Confirm each step is complete before proceeding:

  1. GitHub CLI (gh) is installed and version 2.40.0+
  2. You are authenticated with gh auth login
  3. Copilot extension is installed with gh extension install github/gh-copilot
  4. gh copilot --help shows the available commands
  5. gh copilot suggest "hello" returns a result