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:
- 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
# Using Homebrew (recommended) $ brew install gh # Or using MacPorts $ sudo port install gh # Or download from https://cli.github.com
Linux
# 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
# 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:
$ gh --version # gh version 2.62.0 (2024-12-05)
brew upgrade gh).
Step 2: Authenticate with GitHub
Before installing the Copilot extension, you need to authenticate with your GitHub account:
$ 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:
$ 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:
$ gh extension install github/gh-copilot # You should see: # Installed extension github/gh-copilot
If you already have it installed and want to update:
# 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:
# 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"
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"
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:
$ gh extension upgrade gh-copilot
"Your account does not have Copilot access"
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:
# 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:
# 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:
- GitHub CLI (
gh) is installed and version 2.40.0+ - You are authenticated with
gh auth login - Copilot extension is installed with
gh extension install github/gh-copilot gh copilot --helpshows the available commandsgh copilot suggest "hello"returns a result
Lilly Tech Systems