Using Git and GitHub CLI on Linux¶
This guide explains how to install and authenticate the GitHub CLI (
gh
) on Linux. It is intended for technical users and assumes no prior experience with the GitHub CLI.
Install GitHub CLI (gh
) on Linux¶
Run the following commands in your terminal:
sudo mkdir -p -m 755 /etc/apt/keyrings
wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh -y
Authenticate to GitHub¶
After installing, run:
Follow the interactive prompts: - Choose your account (e.g., GitHub.com) - Select HTTPS as the protocol - Authenticate with your GitHub credentials - Use a web browser for authentication (copy the one-time code and open the provided URL if your browser does not open automatically)
You should see confirmation messages when authentication is complete.