Github CLI - bring Github to the command line
Tags: git, beginners, tutorial, productivity
Published: 2020-09-05 08:35:32

---
title: Github CLI - bring Github to the command line
published: true
tags: git, beginners, tutorial, productivity
canonical_url: https://gitbetter.substack.com/p/git-cli-bring-github-to-the-command
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/mpbazueac2nzq7vjxd3h.png
---
> #### This post was originally posted in the newsletter [GitBetter](https://gitbetter.substack.com/). If you are interested in leveling up your game in Git, you can subscribe to it.

Github CLI is one of the useful tools you can start using right away if you are a very active Github user.

You can visit the [repo here](https://github.com/cli/cli).

This is still in beta but you can still use it. It brings PRs, issues, and other useful features of Github to the command line.

I will cover some commands that I find very useful. And you can also play around with the tool.

#### Listing Pull requests

You can list all the PRs of the repo.

```
gh pr list
```

There are options for filtering PRs with the assignee, base branch, labels.

**Examples** :

```
gh pr list --label "WIP, help" // List PRs with the provided labels

gh pr list --base "master" // List PRs with master as base

gh pr list --assignee "john" // List PRs with the respective assignee
```

#### Creating a Pull request

Creating a PR is very easy with CLI. This can make you really productive.

```
gh pr create
```

The above command is a very basic option. This will create a PR with the _ **master** _ as the base branch and the _ **current branch** _ as the target branch.

There are other options as well for changing the base branch, labeling, assigning people, etc

**Examples** :

```
gh pr create --base develop // Here develop is the base branch

gh pr create --title "PR title" // Create a PR with title

gh pr create --reviewer "john, arya" // Assign reviewers

gh pr create --label "prod, help" // Assign labels
```

#### View Pull request change

```
gh pr diff <PR number / url>

Example
gh pr diff 3
```

The above command will show the diff of the respective PR. This will come in handy if you are looking for small changes in PR.

#### Creating an issue

Creating a simple issue from the CLI will come in handy often.

```
gh issue create --title "Search not working" --body "Search in main dashboard is not working"
```

The above command will create a new issue with the respective title and body.

There are like other useful options too

**Examples**

```
gh issue create --label "help, priority" // You can assign multiple labels

gh issue create --assignee "john, arya" // You can assign people
```

#### Listing issues

```
gh issue list
```

This will list all issues.

**Examples**

```
gh issue list --label "help, priority" // List issues by labels

gh issue list --assignee "john, arya" // List issues by assignees

gh isssue list --author "srebalaji" // Lists issues by people who created the issue
```

#### Creating gist

This is one of my favorites. You can create a public or private gist from the command line itself.

```
gh gist create main.js
```

The above command will create a private gist with the given file.

By default, gists are made private.

Other options,

```
gh gist create --public main.js // Creating a public gist

gh gist create main.js -d "NodeJS example" // Creating a gist with a description

gh gist create main.py copy.py home.py // Creating a gist with multiple files

```

Github CLI is a very useful command-line tool you can use. I have been using it for a couple of weeks and I can say it’s very useful. Of course, there are some hiccups but I believe it will be resolved in the upcoming versions.

Highly recommended if you are using Github often.

Thank you for reading :)

> #### This post was originally posted in the newsletter [GitBetter](https://gitbetter.substack.com/). If you are interested in leveling up your game in Git, you can subscribe to it.