Upgrade the GitHub CLI


Step 1: Check Your Current Version

Before upgrading, it’s helpful to know which version you are currently running. Open your terminal and type:

Bash

gh --version

If you see a version number and a notification that a newer version is available, it’s time to update!


Step 2: Upgrade Based on Your OS

macOS

If you installed GitHub CLI using Homebrew (the most common method for Mac users), upgrading is a simple one-liner:

Bash

brew upgrade gh

Windows

On Windows, your upgrade path depends on how you originally installed it:

  • WinGet:PowerShellwinget upgrade --id GitHub.cli
  • Chocolatey:PowerShellchoco upgrade gh
  • Scoop:PowerShellscoop update gh
  • MSI Installer: If you used the .msi installer, simply download the latest version from the official releases page and run it; it will overwrite the old version.

Linux

For Linux users, you’ll typically use your package manager.

  • Ubuntu / Debian / Raspberry Pi OS:Bashsudo apt update sudo apt install gh
  • Fedora / CentOS:Bashsudo dnf upgrade gh
  • Arch Linux:Bashsudo pacman -Syu github-cli

Step 3: Verify the Upgrade

Once the process finishes, verify that you are on the latest version by running the version command again:

Bash

gh --version

Bonus: Keeping Authenticated

Upgrading shouldn’t affect your login status, but if you ever run into permission issues after an update, you can re-authenticate easily:

Bash

gh auth login

Adding a Local Repository to GitHub Using GitHub CLI

 Create a new repository with GitHub CLI

  • Use the gh repo create command to create a repository for your project directly from the command line.
  • When prompted, choose “Push an existing local repository to GitHub” and enter your preferred repository name.
  • If you want the project to be created under an organization rather than your personal account, specify it as:gh repo create ORGANIZATION-NAME/PROJECT-NAME
  • Follow the interactive prompts
    • The CLI will guide you through setup options.
    • When asked whether to add the remote and push commits to your current branch, select Yes to complete the setup.
  • Skip prompts with command flags (optional)
    • To automate the process, include flags directly in your command:gh repo create --source=. --public --remote=origin --push
    • Here’s what each flag does:
      • --source=. → Uses your current directory as the repository source.
      • --public--private, or --internal → Sets repository visibility.
      • --remote → Specifies the remote name (commonly origin).
      • --push → Pushes all existing commits to GitHub automatically.
  • Learn more
    • See the official GitHub CLI Manual for additional flags, examples, and usage tips.

Adding a local repository to GitHub using Git

🚀 Steps to Add a Local Repository to GitHub Using Git

  • Authenticate to GitHub on the command line
  • Create a new repository on GitHub
  • Copy the remote repository URL
    • On the repository’s Quick Setup page, click the copy icon next to the URL to copy it to your clipboard.
    • (You’ll use this URL in the next command.)
  • Open Git Bash
  • Navigate to your local project directory
    • Use the cd command to switch to the folder containing your local repository.cd path/to/your/project
  • Add the remote repository URL
    • Run the following command to link your local repo to the remote GitHub repo:git remote add origin REMOTE-URL
    • Replace REMOTE-URL with the actual GitHub repository URL you copied earlier.
    • More info: Managing remote repositories
  • Verify the remote connection
    • Confirm that the remote URL is set correctly by running:git remote -v
  • Push your local repository to GitHub
    • Upload your local files to the GitHub repository using:git push origin main
    • If your default branch is named something other than main (e.g., master or dev), replace main with your branch name.
    • Learn more: About branches

Clone a particular repo within a github org

The following post outlines a scenario where you need to clone a repo within a github organization .
To clone a repo you use
git clone https://github.com/YOUR-ORGANIZATION/REPO-NAME
however if you use it for a repo that resides within an organization , as of date you will end up with an error :
fatal: repository ‘https ://github.com/ORGNAME/REPO-Name.git/’ not found
The solution is to use the following comand
git clone https://username@github.com/YOUR-ORGANIZATION/REPO-NAME.git
You’ll be prompted to enter your password or token
Hope this helps someone who faces this issue .