Try gh, GitHub's new CLI
Tags: vscode, github, webdev
Published: 2020-04-11 02:12:59

---
title: Try gh, GitHub's new CLI
published: true
description: Try the new gh CLI. It's GitHub on the command line, and it’s now available in beta.
tags: vscode, GitHub, webdev
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/ewy2fu3ex6u7mbs5d3qh.png
canonical_url: https://johnpapa.net/try-githubs-new-cli-gh/
---

Quiz: What do you use every day, that is essential to your development workflow, and has a vast and complex UI and API?

Answer: GitHub, of course!

You likely interact with the `git` commands in terminal for some operations and then go to the <https://github.com> web site when you need to perform other operations. This back and forth between terminal and the browser to perform git operations could be more efficient if you could stay in one zone: CLI or the browser: Well, the GitHub team has felt this too.

They have released a new CLI called `gh`, in beta.

## Resources first

If you are in a hurry, here are all of the links you'll need, in one place:

- [Install `gh`](https://github.com/cli/cli#installation)
- [the `gh` docs](https://cli.github.com/manual/)
- [short survey on `gh`](https://forms.gle/umxd3h31c7aMQFKG7)
- And if you feel motivated, here is your [Free Azure Trial](https://azure.microsoft.com/free/?wt.mc_id=devto-blog-jopapa)

## Install gh

First, [install `gh` using the appropriate instructions for your OS](https://github.com/cli/cli#installation).

You can check your version at anytime with the following command.

```bash
gh --version
```

## Awesome Possibilities

### { 1 } Create an issue

You're working on your code and you run into a bug. But you are busy working on another challenge and don;t want to get distracted. Now you can run a quick command to create an issue without leaving your terminal!

This is awesome! Now you can stay focused on your current work and get back to this later.

```bash
gh issue create -t "Save invokes a 500 error" -b "steps to reproduce: fill out the form, then press save."
```

### { 2 } View issues

Want to see what issues are open?

```bash
gh issue status
```

This produce the following output format:

```bash
Relevant issues in johnpapa/hello-worlds

Issues assigned to you
  There are no issues assigned to you

Issues mentioning you
  There are no issues mentioning you

Issues opened by you
  #1  Save invokes a 500 error    about 1 minute ago
```

### { 3 } Create a repo

You know how sometimes you want to create a repo locally and in GitHub from your computer? Use the following command and you can create a repo named `hello-world`, add a description, and make the repo public!

```bash
gh repo create hello-world -d "A react app for the web" --public
```

### { 4 } Open the browser to your repo

You're working on your code locally and you want to go visit the repo in the browser. Now you have to go type in that URL in the address bar. Nope! Run the following command from your code's local folder and the browser opens right to your repo!

```bash
gh repo view
# this will open your repo, such as https://github.com/johnpapa/hello-world
```

### { 5 } Clone a repo

You can run some common commands like cloning a repo too.

```bash
gh repo clone git@github.com:johnpapa/hello-world.git
```

### { 6 } Fork a repo

Want to fork a repo? How about fork it and clone it locally to your computer? Try this command.

```bash
gh repo johnpapa/hello-worlds fork --clone
```

### { 7 } Create a pull request

You've made your changes to your branch and now it is time to create a Pull Request (PR). You could go to the browser, browse to your repo, and start clicking around to create the PR. Or you could use the following command to create a PR!

The `--fill` flag indicates that you won't be prompted for title/body. Instead it will just use the commit info for those.

```bash
gh pr create --fill
```

### { 8 } Help commands

A great place to start is with the `--help` flag. You can show the options available for any command by appending the `--help` flag.

**get help on commands**

```bash
gh --help
```

**sub commands**

```bash
gh issue --help
gh pr  --help
gh repo --help
```

**pr commands**

```bash
gh pr checkout --help
gh pr create --help
gh pr list --help
gh pr status --help
gh pr view --help
```

**repo commands**

```bash
gh repo clone --help
gh repo create --help
gh repo fork --help
gh repo view --help
```

**issue commands**

```bash
gh issue create --help
gh issue list --help
gh issue status --help
gh issue view --help
```

## { 9 } Read the docs

There is a lot more that you can do, so go ahead and [read the `gh` docs](https://cli.github.com/manual/).

## { 10 } git is still awesome

No worries, you can mix and match using the `git` commands and the `gh` commands.

## Summary

Give it `gh` a try! [GitHub is accepting feedback now during their beta through this short survey](https://forms.gle/umxd3h31c7aMQFKG7).