Your Search Bar For Shrewd Tips

How To Install Github Cli


How To Install GitHub CLI

If you're a developer or someone who frequently interacts with GitHub repositories, the GitHub CLI (Command Line Interface) is an essential tool that streamlines your workflow. It allows you to manage issues, pull requests, and repositories directly from your terminal, saving you time and effort. Installing GitHub CLI is straightforward and can be accomplished on various operating systems. In this guide, we'll walk you through the step-by-step process to install GitHub CLI on Windows, macOS, and Linux, ensuring you're set up to enhance your GitHub experience.

Prerequisites for Installing GitHub CLI

Before proceeding with the installation, ensure your system meets the following prerequisites:

  • Access to a terminal or command prompt (PowerShell, Terminal, Bash, etc.)
  • Administrator or sudo privileges on your computer
  • Internet connection to download the installer or package

Installing GitHub CLI on Windows

Windows users have multiple options to install GitHub CLI, including using the Windows Installer, package managers like Chocolatey, or Windows Package Manager (winget). Below are the most common methods:

Method 1: Using the Windows Installer

  1. Visit the official GitHub CLI releases page: https://github.com/cli/cli/releases.
  2. Download the latest gh_x.x.x_windows_amd64.msi installer file.
  3. Run the installer and follow the on-screen instructions to complete the installation.
  4. Once installed, open Command Prompt or PowerShell and verify the installation by typing:
    gh --version
    You should see the version number of GitHub CLI displayed.

Method 2: Using Chocolatey Package Manager

  1. Open an elevated Command Prompt or PowerShell window.
  2. If you haven't installed Chocolatey, follow the instructions at https://chocolatey.org/install.
  3. Install GitHub CLI by running:
    choco install gh
  4. After installation, confirm by typing:
    gh --version

Method 3: Using Windows Package Manager (winget)

  1. Open Command Prompt or PowerShell.
  2. Run the following command:
    winget install --id=GitHub.cli --source=winget
  3. Verify installation:
    gh --version

Installing GitHub CLI on macOS

Mac users can install GitHub CLI via Homebrew, MacPorts, or by downloading the package directly.

Method 1: Using Homebrew

  1. Open Terminal.
  2. If you don't have Homebrew installed, install it by running:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. Once Homebrew is ready, install GitHub CLI with:
    brew install gh
  4. Verify the installation:
    gh --version

Method 2: Downloading the Binary

  1. Visit the GitHub CLI releases page: https://github.com/cli/cli/releases.
  2. Download the latest gh_x.x.x_macOS.tar.gz file.
  3. Extract the archive and move the gh binary to a directory in your PATH, such as /usr/local/bin.
  4. Make the binary executable:
    chmod +x /usr/local/bin/gh
  5. Check the version:
    gh --version

Installing GitHub CLI on Linux

Linux distributions support GitHub CLI through various package managers. The installation process varies based on your distro.

Method 1: Using apt (Debian/Ubuntu)

  1. Open your terminal.
  2. Update your package list:
    sudo apt update
  3. 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
    echo "deb [arch=$(dpkg --print-architecture)] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
  4. Update package list again:
    sudo apt update
  5. Install GitHub CLI:
    sudo apt install gh
  6. Verify the installation:
    gh --version

Method 2: Using yum/dnf (Fedora/CentOS)

  1. Open Terminal.
  2. Add the repository and install:
    sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
    sudo dnf install gh
  3. Check the version:
    gh --version

Method 3: Using Snap (Universal Linux Method)

  1. Ensure snapd is installed and enabled.
  2. Install GitHub CLI:
    sudo snap install gh --classic
  3. Verify:
    gh --version

Post-Installation: Authenticating with GitHub CLI

After installing GitHub CLI, you'll need to authenticate to access your repositories and perform various tasks. To authenticate, simply run:

gh auth login

This command guides you through the authentication process, allowing you to log in via your browser or provide a personal access token. Once authenticated, you can start managing issues, pull requests, and repositories directly from your terminal.

Using GitHub CLI Effectively

Now that you have installed and authenticated GitHub CLI, here are some common commands to get you started:

  • Clone a repository: gh repo clone owner/repo
  • Create a new issue: gh issue create
  • List open pull requests: gh pr list
  • Checkout a pull request: gh pr checkout 123
  • Create a new repository: gh repo create
  • View repository details: gh repo view

Conclusion

Installing the GitHub CLI is a valuable step toward streamlining your development workflow. Whether you're using Windows, macOS, or Linux, the process is simple and can be tailored to your preferred method, whether via native installers, package managers, or direct downloads. Once installed and authenticated, the CLI empowers you to manage your GitHub repositories more efficiently, perform common tasks faster, and stay productive from your terminal. Embrace the power of GitHub CLI today and take your project management to the next level!


Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.

Shrewdnia

Shrewdnia

Shrewdnia is a destination for curious minds seeking clarity, knowledge, and informed perspectives. Through insightful articles and practical guides our passionate team explores a wide range of topics designed to help readers understand the world around them, make smarter decisions, and stay informed in an ever-changing landscape.


💡 Every question sparks discovery, and every perspective enriches the conversation. Share your thoughts and insights in the comments 👇

Back to blog

Leave a comment

JOIN THE SHREWDNIA COMMUNITY FORUM

What do you think?

Have an opinion, experience, or question about this topic? Join the Shrewdnia Forum and share your thoughts with other readers.

Join the Forum →