Skip to content

Using the GitHub CLI

The GitHub CLI, or gh, is a command-line interface to GitHub for use in your terminal or your scripts. - View the GitHub CLI installation instructions

Configuration

Run gh auth login to authenticate with your GitHub account. Alternatively, gh will respect the GITHUB_TOKEN environment variable.

To set your preferred editor, use gh config set editor <editor>. Read more about gh config and environment variables.

Declare your aliases for often-used commands with gh alias set.

Sign in to GitHub

Follow these steps once you have followed the GitHub CLI installation instructions

  1. In your terminal, issue gh auth login and follow the prompts
    gh auth status
    

Verify you are signed in to GitHub

Ensure you are signed in to GitHub with the CLI using gh auth status

  1. Check the GH authentication status with

    gh auth status
    

  2. Ensure the output shows

    github.com
       Logged in to github.com as GH_USERNAME (/home/USER/.config/gh/hosts.yml)
       Git operations for github.com configured to use https protocol.
       Token: *******************
    

  3. If needed, login to GitHub with gh auth login and follow the prompts

Next steps

Read through the GitHub CLI manual to learn more. - Available commands - Usage examples - Community extensions