How to use the GitHub CLI app on Windows and WSL

There’s no need to keep going to your browser or a desktop app, do all of your GitHub-ing from the command line.

When you purchase through links on our site, we may earn an affiliate commission.Here’s how it works.

Microsoft-ownedGitHubis the biggest code-sharing platform on the planet and while using it through the web browser is simple, when you’re interacting with your code and local files you’re more than likely using a terminal.

That’s where GitHub CLI comes in. An official tool made by GitHub, it’s good to use both on Windows 10 andWindows 11in PowerShell or within theWindows Subsystem for Linux (WSL). Once you’re familiar with it, it could speed up a number of areas of your GitHub workflow.

Here’s how to install it, get set up and carry out some basic processes.

Set up a GitHub account before anything else

Set up a GitHub account before anything else

You don’t need a GitHub account to browse code and clone repos, but it’s still worth signing up. Only with your own account and repo space can you store your own files and fork other projects, follow other members, and star repos for easy access later on. It’s completely free to use and doesn’t require you to have a Microsoft Account.

A GitHub account also allows you to make use of the oft-overlooked GitHub CLI terminal application, which due to some changes in how GitHub allows accounts to be authenticated, is actually something you should have. More on that later.

You don’thaveto interact with GitHub through the terminal, but in many cases, it’s the most efficient workflow.

Installing GitHub CLI onto Windows or WSL

Installing GitHub CLI onto Windows or WSL

The GitHub CLI tool is an official GitHub application, and if you’re going to be using GitHub, it’s well worth having. For one, it gets around using personal access tokens with Git to push local repositories up to GitHub, as you can use the GitHub CLI application to authenticate your whole system.

Get the Windows Central Newsletter

All the latest news, reviews, and guides for Windows and Xbox diehards.

To install the GitHub CLI on Windows you can use theWindows Package Manageragain by entering this into PowerShell.

Alternatively, you can grab it directly from GitHub and it’s also available through the Scoop and Chocolately package managers, too.

On WSL, the process is a little more involved, butGitHub has full documentationyou can follow. Since most people using WSL are likely to have Ubuntu or Debian installed as they’re officially distributed through the Microsoft Store, you can use the following commands in your WSL terminal to install it.

As with Git, the WSL installation of the GitHub CLI is separate from the Windows installation you would use in PowerShell. The two operate the same way, but if you switch between WSL and PowerShell, you’ll need to have it installed in both locations.

How to set up GitHub CLI and authenticate your account

The GitHub CLI, unlike Git,canuse your account login and password for authentication with the added bonus of then also allowing Git to push to your GitHub repositories. To authenticate GitHub CLI, open up your terminal and follow these steps. Again, all the steps are the same whether you use Windows or WSL.

You’ll now be logged into the GitHub CLI client. To see the full list of commands available simply type:

Using GitHub CLI

There is a basic command template for using GitHub CLI that looks like this:

All commands you enter will begin with “gh” in order to trigger GitHub CLI. There are a number of commands to use, but here are some examples of how you would carry out some basic functions.

Create a new GitHub repository

GitHub CLI gives you the ability to create a new remote repository without having to first go to the GitHub website and then link it back to your local machine. To do so you need to have Git initialized in your local directory and then navigate there in the terminal. Then enter:

You’ll be asked to give it a name, an optional description, its visibility and to confirm you want to create an “origin” Git remote in your local directory. Once all are completed, you can go check out your new repo on the GitHub website. You can open up this or any of your other GitHub repos from their local directories by entering:

Clone or fork a GitHub repository

Most of the time you’ll use the “git clone” command to clone a local copy of a GitHub repository, but you can do the same using the GitHub CLI tool using this command.

So, for example, to clone Microsoft Visual Studio you would simply enter:

The end result is the same as using Git, and a new directory will be created on your local machine with all contents of the remote repository contained within. You can also use GitHub CLI to clone repos with the full URL if you have that instead, and using the same command without the username will allow you to clone your own repos easily.

You can also use GitHub CLI to fork a repository and clone a local copy if you wish. You don’t have to clone it, however, but it’s a quick way to achieve both goals with one command.

For example:

Once you hit Enter, you’ll be asked whether you want to clone the fork or not.

The GitHub CLI tool also has an easy way to find repos you might want to clone, assuming you know the organization or username. For example, to see all Microsoft repositories on GitHub you might enter:

Creating a new issue

Creating issues is a key part of the GitHub process, and you can do that right from the command line using this command.

The tool will then ask you to give your issue a title, followed by opening a text editor, such as Nano in WSL, to fill out the body of the issue, then the option to submit or to continue in the browser. It’s really straightforward, and the prompts will guide you at every step.

Viewing and closing issues

To get a full list of the available tools for the issue in question use this command:

One of the most common you’ll want to use is viewing issues and then closing them if dealt with. To view all issues for your GitHub repository, enter this command.

You’ll now be given a printout of all issues submitted to that repository. To close off issues that have been dealt with, take note of the issue number and enter this command.

You’ll be given a confirmation that the issue has closed, and to confirm you can run the list command again, and it should be gone.

Creating a pull request

There are a number of options you have when creating pull requests in GitHub CLI, but the basic template is as follows.

At any time, you can add “–help” to the above to get a full breakdown of all available options. If you wanted to create a pull request and continue it on the web, for example, you would enter:

Pull requests behave in exactly the same way as on the web, so naturally won’t work if you’re on the master branch.

There’s alotmore to GitHub CLI than we’ve talked about here, but hopefully, this gets you pointing in the right direction, particularly if you’re a beginner to using GitHub at all. We have a fullbeginner’s guide to GitHubthat’s a good companion to this, but once you’re comfortable with the basics there’s a lot to explore. Most of GitHub’s main features can be interacted with using the CLI tool.

If at any point you need a bit more information, the “–help” flag after a command is your friend, as it’ll break down everything you can do with every possible command available in GitHub CLI.

Richard Devine is a Managing Editor at Windows Central with over a decade of experience. A former Project Manager and long-term tech addict, he joined Mobile Nations in 2011 and has been found on Android Central and iMore as well as Windows Central. Currently, you’ll find him steering the site’s coverage of all manner of PC hardware and reviews. Find him on Mastodon atmstdn.social/@richdevine