Experiments with GitHub CLI
Abhishek Pokhriyal
October 1, 2020

Something caught my eyes when I opened up my GitHub account a few days back. In the spotlight, GitHub was flaunting the launch of version 1.0 of their CLI.

As a command-line fanatic, I knew I have to check this thing. And that’s exactly what I did, I installed it on my machine and started playing. So, here I’m writing about everything I’ve explored so far.


Installation was pretty straightforward (at least on macOS). I use Homebrew so all I had to do was:

brew install gh

After installation, I ran some generic commands:

gh --version    # Checking the CLI version
gh --help       # See the available commands

Connecting with GitHub account

The CLI offers a very interactive command to connect with your GitHub account:

gh auth login

Some questions will be asked, and (don’t worry) there will be options you’ll need to select (using the arrows and hitting Enter)

  1. What account do you want to log into?
    1. GitHub.com 👈
    2. GitHub Enterprise Server
  2. How would you like to authenticate?
    1. Login with a web browser 👈
    2. Paste an authentication token
  3. A one-time code will appear on the terminal (something like 54F4-9F4E). Copy that code and hit Enter to open the web browser for authentication.
  4. Complete the authentication and authorization process from the web browser and when it says Congratulations, you're all set!, close the browser tab, and return back to the terminal.
  5. On the terminal, you’d see Authentication complete. Press Enter to continue…. Hit Enter.
  6. That’s it…Well, that’s not it! It asks one more question.
  7. Choose default git protocol
    1. HTTPS 👈
    2. SSH
  8. Now, that’s it. It’ll say Logged in as your-github-username and the interactive session will end.

Get started

Let’s start by building our playground.

Creating a repository

gh repo create gh-cli-experiments

Few questions will be asked, some confirmations will be taken, and the result will look like this: https://github.com/abhishek-pokhriyal/gh-cli-experiments.

Creating issues

Now that we have a brand new repository, let’s create some issues.

gh issue create -R abhishek-pokhriyal/gh-cli-experiments

The -R option is to specify the repository on which I’m opening the issue.

There are a lot of options available when you create an issue. You don’t need to remember that, just run

gh issue create --help

I saw some of the options and then ran this command:

gh issue create --title "Add License" --assignee abhishek-pokhriyal -R abhishek-pokhriyal/gh-cli-experiments

and I got this: https://github.com/abhishek-pokhriyal/gh-cli-experiments/issues/2.

Listing issues

Want to keep a track on the list of issues? Run:

gh issue list -R abhishek-pokhriyal/gh-cli-experiments

and get this pretty list outputted on your terminal.

What else

Well, running gh --help reveals quite a few commands classified as Core and Additional ones. The core ones (as of now) are

  1. gist
  2. issue
  3. pr
  4. release
  5. repo

This means you can manage gists, issues, pull requests, releases, and repositories straight from the command-line. That’s a lot for v1.0.0.

Where from here?

So that was all, my very first experience playing with the GitHub CLI. If you’re excited and would like to dig deeper, you can check out the official manual. Also, if you’re interested in the development of the CLI, would like to report a bug, or have a feature request, you can do so in their open-source GitHub repository.

One of the advantages of CLI tools is that they can significantly help in improving the processes by automating chores. The possibilities are endless, so if you’ve any thoughts or suggestions for bringing the GitHub CLI into the software development processes, please do share those in the comments.

The possibilities are endless. Keep experimenting!