GitHub Copilot
GitHub Copilot is GitHub's official AI-powered coding assistant. It provides intelligent code completions, chat-based programming help, and a command-line tool that can suggest and explain shell commands. With deep integration into the GitHub ecosystem, Copilot works seamlessly with repositories, pull requests, and issues. The CLI extension brings AI assistance directly to your terminal, while editor extensions provide inline completions in VS Code, JetBrains, and other editors.
Prerequisites
Before installing GitHub Copilot, make sure you have the following:
- GitHub account -- Required for authentication.
- GitHub Copilot subscription -- Copilot requires an active subscription (Individual, Business, or Enterprise). A free tier with limited usage is available for verified students, teachers, and open-source maintainers.
- GitHub CLI (
gh) -- Required for the Copilot CLI extension.
TIP
You can check your Copilot subscription status at github.com/settings/copilot.
Installation
Step 1: Install the GitHub CLI
The GitHub CLI (gh) is the foundation for the Copilot command-line extension.
# Install the GitHub CLI from the official Debian repository
sudo apt update
sudo apt install -y gh
# Verify the installation
gh --versionIf gh is not available in your Debian repositories, install it from the official source:
# Add the GitHub CLI repository
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
# Install gh
sudo apt update
sudo apt install -y ghStep 2: Authenticate with GitHub
Log in to your GitHub account through the CLI:
# Start the authentication flow
gh auth login
# Follow the prompts:
# 1. Select "GitHub.com"
# 2. Choose your preferred authentication method (browser or token)
# 3. Complete the login processVerify your authentication:
# Check authentication status
gh auth statusStep 3: Install the Copilot CLI Extension
# Install the GitHub Copilot CLI extension
gh extension install github/gh-copilot
# Verify the installation
gh copilot --versionInstalling the VS Code Extension
For editor-based Copilot features:
# Install the GitHub Copilot extension for VS Code
code --install-extension GitHub.copilot
# Install the Copilot Chat extension for conversational AI
code --install-extension GitHub.copilot-chat
# Verify the extensions are installed
code --list-extensions | grep -i copilotConfiguration
CLI Configuration
The Copilot CLI extension works out of the box once authenticated. You can configure optional settings:
# Set an alias for quicker access
echo 'alias gcs="gh copilot suggest"' >> ~/.bashrc
echo 'alias gce="gh copilot explain"' >> ~/.bashrc
source ~/.bashrcVS Code Configuration
After installing the VS Code extensions:
- Open VS Code.
- Sign in to your GitHub account when prompted.
- Copilot will activate automatically once authenticated.
You can customize Copilot behavior in VS Code settings (Ctrl + ,):
- Enable/disable inline suggestions -- Search for "copilot.enable".
- Configure language-specific behavior -- You can enable or disable Copilot for specific programming languages.
- Adjust suggestion display -- Configure when and how suggestions appear.
Usage
CLI: Suggest Commands
The gh copilot suggest command generates shell commands based on natural language descriptions:
# Get a command suggestion
gh copilot suggest "find all Python files modified in the last 7 days"
# Suggest a Git command
gh copilot suggest "squash the last 3 commits into one"
# Suggest a system administration command
gh copilot suggest "list all listening ports on the system"
# Suggest a command for a specific shell
gh copilot suggest -t shell "compress all log files in /var/log older than 30 days"When Copilot suggests a command, you can:
- Run it directly from the prompt.
- Copy it to your clipboard.
- Revise it by providing additional context.
- Rate it to help improve future suggestions.
CLI: Explain Commands
The gh copilot explain command breaks down complex shell commands into plain language:
# Explain a complex command
gh copilot explain "find . -type f -name '*.log' -mtime +30 -exec gzip {} \;"
# Explain a Git command
gh copilot explain "git rebase -i HEAD~5"
# Explain a networking command
gh copilot explain "ss -tulnp"
# Explain a pipeline
gh copilot explain "ps aux | awk '{print \$2, \$11}' | sort -k2"VS Code: Inline Completions
In VS Code, Copilot provides real-time code suggestions as you type:
- Accept a suggestion: Press
Tab. - Dismiss a suggestion: Press
Escape. - See alternative suggestions: Press
Alt + ]orAlt + [. - Trigger a suggestion manually: Press
Alt + \.
VS Code: Copilot Chat
Open the Copilot Chat panel for conversational interactions:
- Press
Ctrl + Shift + Ito open Copilot Chat. - Ask questions about your code, request explanations, or describe changes you want.
- Use
@workspaceto reference your entire project context.
Example prompts:
@workspace How does the authentication module work?
Explain the error in the selected code
Write a unit test for this function
Refactor this code to improve performanceVS Code Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Tab | Accept inline suggestion |
Escape | Dismiss suggestion |
Alt + ] | Next suggestion |
Alt + [ | Previous suggestion |
Alt + \ | Trigger suggestion manually |
Ctrl + Shift + I | Open Copilot Chat |
Update
Updating the CLI Extension
# Update the Copilot CLI extension
gh extension upgrade github/gh-copilot
# Verify the new version
gh copilot --versionUpdating the VS Code Extensions
VS Code extensions update automatically. To manually check:
- Press
Ctrl + Shift + Xto open the Extensions panel. - Check for available updates on the GitHub Copilot extensions.
Or force an update from the terminal:
# Force reinstall the latest version
code --install-extension GitHub.copilot --force
code --install-extension GitHub.copilot-chat --forceUninstalling
# Remove the CLI extension
gh extension remove github/gh-copilot
# Remove the VS Code extensions
code --uninstall-extension GitHub.copilot
code --uninstall-extension GitHub.copilot-chatTroubleshooting
"gh copilot" command not found
If gh copilot is not recognized after installation:
# Check installed extensions
gh extension list
# If gh-copilot is not listed, reinstall it
gh extension install github/gh-copilot
# If gh itself is not found, check your PATH
which ghAuthentication issues
If Copilot cannot authenticate:
# Check your current authentication status
gh auth status
# If not authenticated, re-login
gh auth login
# Refresh your authentication token
gh auth refresh -s copilotCopilot not providing suggestions in VS Code
If inline completions are not appearing:
- Check subscription -- Make sure your Copilot subscription is active at github.com/settings/copilot.
- Check extension status -- Look for the Copilot icon in the VS Code status bar. A spinning icon means it is processing; a crossed-out icon means it is disabled.
- Check language support -- Copilot may be disabled for certain file types. Go to Settings and search for "copilot.enable".
- Restart VS Code -- Sometimes a simple restart resolves connectivity issues.
Network or proxy errors
If you are behind a corporate proxy:
# Configure Git proxy settings (used by gh)
git config --global http.proxy http://your-proxy:port
git config --global https.proxy http://your-proxy:port
# Set environment variables for the CLI
export HTTP_PROXY="http://your-proxy:port"
export HTTPS_PROXY="http://your-proxy:port"
# Test connectivity
gh api rate_limitRate limiting or quota errors
If you hit usage limits:
- Check your subscription tier -- free tier has limited monthly usage.
- Wait for the rate limit to reset (usually resets monthly).
- Consider upgrading to a paid plan for higher limits.
# Check your current rate limit status
gh api rate_limitRelated Resources
- AI Tools Overview -- Overview of all AI tools on Debian
- Command Line Basics -- Terminal fundamentals
- GitHub Copilot Documentation -- Official GitHub Copilot docs
- GitHub CLI Documentation -- Official gh CLI manual