TL;DR

  • The GitHub CLI replaces the hub if you’re using only github.com
  • GitHub Enterprise is not supported now (as of 2020/4/24), so it’s not a replacement for hub for my use. The GitHub CLI now supports GHE !! See GA for more info.

Motivation

Since GitHub CLI can do more things, I investigated whether I can migrate from hub, which is usually used as a CLI client of GitHub.

Repository Manipulation

The only repository command I may use is as follows

$ gh repo view -w # Show current repository in a browser.

Issue Manipulation

Here are the basic issue commands and options that I might use.

$ gh issue create # create an issue on a terminal
$ gh issue list -L 200 # show up to 200 results in a search (default 30)
$ gh issue list -a takanabe # use assignee:takanabe to search for an issue
$ gh issue list -l Type:Reactive # use label:Type:Reactive to search for an issue.

The create command is useful because you can interactively enter the items needed to create an issue in your favorite editor, and you can also use the GitHub issue template. Editors should be configured with environment variable of EDITOR=nvim, or with gh config command. The list command is more useful with interactive filters such as peco. For example, the following usage.

$ gh issue list -L 200 | peco | cut -f 1 | xargs -I % gh issue view % # peco view the selected issue in the terminal.
$ gh issue list -L 200 | peco | cut -f 1 | xargs -I % gh issue view % -w # View the selected issue with peco in your browser.
$ gh issue list -a takanabe -l Type:Reactive -L 200 | peco | cut -f 1 | xargs -I % gh issue view % # filter the label and assignee and show the selected items in terminal with peco.

Pull Request Manipulation

Here are the basic pull request commands and options that I might use.

$ gh pr checkout 1 # fetch a branch of PR and checkout. The one I've been working on below.
$ # git fetch origin refs/pull/1/head
$ # git checkout -b USER/BRANCH_NAME FETCH_HEAD
$ gh pr create -f # Create a PR without opening the web
$ gh pr create -df # Create a draft PR without opening browser
$ gh pr create -dwf # Create  a draft PR with a web browser 
$ gh pr list # Display a list of PRs.

As with the issue command, it is more useful in combination with peco.

$ gh pr list | grep `git branch --show-current` | cut -f 1 | xargs -I % gh pr view % # open the current branch's PR with terminal.
$ gh pr list | grep `git branch --show-current` | cut -f 1 | xargs -I % gh pr view % -w # Open the current branch's PR in a browser.

If I use alias for the commands introduced above, it will cover what I did with hub, and it looks good.

Advantages of GitHub CLI

The best thing about the GitHub CLI is that I can create issues and PRs interactively from my terminal. In addition, gh pr create -f completes a PR creation without opening a web browser. This is super cool. Sooner or later, issues will be able to be completed without opening the browser.

GitHub Enterprise support

In my research so far, I’ve found that most of what I was doing with hub is replaceable in the GitHub CLI. I thought it would be good to switch to GitHub CLI until I recognized that it doesn’t support GitHub Enterprise.

While in beta, GitHub CLI is available for repos hosted on GitHub.com only. It does not currently support repositories hosted on GitHub Enterprise Server or other hosting providers. We are planning support for GitHub Enterprise Server after GitHub CLI is out of beta (likely toward the end of 2020), and we want to ensure that the API endpoints we use are more widely available for GHES versions that most GitHub customers are on.

It is not supported now (as of 2020/4/24), so we have to wait until beta is finished.

update

The GitHub CLI now supports GHE on Sep 17, 2020

Summary

Because I use GitHub Enterprise at work, I can’t fully migrate to the GitHub CLI and runbrew unistall hub at the moment. I can’t wait for the GitHub CLI to be GitHub Enterprise ready!!

The GitHub CLI now supports GHE !!

References