はじめに
Filter issues, create pull requests, checkout pull requests locally, and more—all from your command line. GitHub CLI is now in beta.https://t.co/KqoUaepoPu
— GitHub (@github) February 12, 2020
GitHub CLIのベータ版が公開されました。GitHub CLIは、イシューのフィルタリングやプルリクエストの作成、チェックアウトなどを実行可能なコマンドラインツールです。
本記事では、このGitHub CLIの導入とその使い方を紹介します。
GitHub CLIのインストール

Installation instructions
Take GitHub to the command line
macOSの場合、homebrewを使ってGitHub CLIをインストールするには、次のコマンドを実行します。
brew install github/gh/gh
PRの一覧を表示
PRの一覧を表示するときは、pr listを使用します。
オプションで-s、または–stateでopenやclosed、mergedなどのステータスを指定することができます。
$ gh pr list
Pull requests for golang/go
#37228 errors: add new function Temporary(error) bool aka-rider:errors-temporary
#37167 crypto/tls: This change removes the size parameter from the Generate functions brompwnie:patch-1
#37148 src/runtime/testdata/testprogcgo: fix goroutine leak on timeout BurtonQin:bug-3-goroutine-leak
#37143 net/textproto, sync: add unlock before panic BurtonQin:bug-1-missing-unlock
#37125 doc: Rewrite godoc.org links to pkg.go.dev simon04:pkg.go.dev
#36989 cmd/go/internal/vet: print line numbers appropriately on list errors nicks:nicks/vet
#36979 os: document Pid field from Process tiriplicamihai:add-comment-to-exec-pid
#36966 net/mail: skip empty entries in parseAddressList timmydo:timmydo/obs-addr-list
#36945 crypto/x509: add RFC 5280/X509v2 compliant CRL generation function rolandshoemaker:x509-create-crl-conform
#36938 encoding/json: fix broken link to json.org jonjohnsonjr:broken-link
#36920 cmd/vendor: create modules.txt even for unused deps jcrowgey:issue36580
#36910 encoding/base64: improve performance up to 40% total kirillx:master
#36903 os: error testing functions respect Unwrapper interface husio:os_errors_unwrap
#36826 os: do not use procfs for os.Executable in dragonfly tuxillo:dragonfly-os-executable
#36815 strconv: Add ParseCompex function pjebs:strconv.ParseCompex
#36783 x/website: Fix wrong variable name HowJMay:fix_doc
#36732 bytes_test: Fix flaky test TestGrow HowJMay:TestGrow
#36727 cmd/dist: ensure that cmd/internal/objabi/zbootstrap.go is cleaned properly SataQiu:fix-clean-20200124
#36715 cmd/go: validate module path in mod why GrigoriyMikhalkin:issue/36658
#36692 html/template: remove RawGit link from docs ncruces:ncruces-rawgit
#36678 net/http/httputil: add support for X-Forwarded-Proto, X-Forwarded-Host and an option to not trust forwarded headers in ReverseProxy dunglas:x-forwarded
#36674 doc/articles/wiki/index.html: Added Missing Package ChiragSukhala:patch-1
#36630 go/constant: remove redundant octal & separator literals parsing vovapi:constant-remove-todo
#36588 fmt: do not remove trailing zeros for %g and %G with #(sharp) flag yah01:master
#36552 runtime/runtime2: pack the sudog struct tenderlove:pack-sudog
#36537 fix of #36535 issue ololosha228:fix-issue/36535
#36500 crypto/tls: create certs w/o KeyEncipherment KU for non-RSA keys in generate_cert.go cpu:cpu-generate-cert-fix-ku
#36454 solves #issues/36450 petar-dambovaliev:issue/36450
#36412 add a scope variable choose sleepingj:master
#36382 net/http: fix Transport upgrading responses for non-keep-alive requests nhooyr:upgrade
PRを指定してチェックアウト
PRブランチをチェックアウトするときは、pr checkoutコマンドを使用します。
引数にはPR番号を指定します。
$ gh pr checkout <number>
例)
$ gh pr checkout 36382
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Total 8 (delta 7), reused 7 (delta 7), pack-reused 1
Unpacking objects: 100% (8/8), done.
From github.com:golang/go
* [new ref] refs/pull/36382/head -> upgrade
Switched to branch 'upgrade'
PRのステータスを表示
pr statusを使用すると、現在のブランチや、自分が作成したPRの状態を確認できます。
$ gh pr status
Relevant pull requests in golang/go
Current branch
#36382 net/http: fix Transport upgrading responses for... [nhooyr:upgrade]
- Checks passing
Created by you
You have no open pull requests
Requesting a code review from you
You have no pull requests to review
Issueの一覧を表示
イシューの表示にはissue listを実行します。
$ gh issue list
Issues for golang/go
#37235 strings: Title and ToTitle have similar names but do different things (Go2)
#37234 x/sys: Missing TIME_OOP and friends (NeedsFix, OS-Linux, help wanted)
#37233 runtime/race: leak in long-running programs, more transparent memory statistics (NeedsInvestigation)
#37232 go.dev: support different GOOS/GOARCH values when displaying package documentation (FeatureRequest, NeedsInvestigation, go.dev)
#37231 x/tools/gopls: language features fail on filenames containing @ (Tools, gopls)
#37230 PowerRegisterSuspendResumeNotification error on Azure App Services with go 1.13.7 ... (CherryPickCandidate)
#37229 PowerRegisterSuspendResumeNotification error on Azure App Services with go 1.13.7 ... (CherryPickCandidate)
#37227 cmd/go: behavior of go list ... is not documented in module mode (Documentation, GoCommand, NeedsInvestigation, …)
#37225 cmd/go: global go get does not reference main package's module's go.sum (GoCommand, NeedsInvestigation, modules)
#37223 x/tools/gopls: using a lot of memory (Tools, gopls)
#37222 spec: valid assignment does not compile but according to https://golang.org/ref/sp... (NeedsInvestigation)
#37221 x/tools/gopls: support `gofmt -s` in formatting (Tools, gopls)
#37220 compile/arm64: - undefined: hooks [windows] (OS-Windows, WaitingForInfo)
#37219 proposal: x/crypto/ocsp: Return ocsp.Request from CreateRequest instead of []byte (Proposal)
#37218 cmd/go: go list incorrectly says that can only use path@version syntax with 'go get' (GoCommand, NeedsFix)
#37217 os/exec: (*SysProcAttr).Foreground causes the spawned process to hang (NeedsInvestigation)
#37216 runtime: invalid pc-encoded table when running Openshift tests using go1.14rc1 on ... (NeedsInvestigation)
#37215 x/tools/gopls: enable debug server and some tracing by default (Tools, gopls)
#37214 cmd/go: "package not found" error is less useful than GOPATH's when the missing pa... (GoCommand, NeedsFix, modules)
#37213 x/tools/gopls: invalidate package IDs (specific to command-line-arguments) (Tools, gopls)
#37211 encoding/xml: Decoder allocates (and does not release) memory for every control <?... (NeedsInvestigation)
#37210 cmd/vet: warn about more malformed JSON struct tags (NeedsInvestigation)
#37208 x/sys/unix: If mips64le termios Ispeed and Ospeed can work (WaitingForInfo)
#37206 testing: when using a custom TestMain, m.Run does not return if one of the tests i... (NeedsInvestigation)
#37205 x/tools/gopls: support and documentation for bazel-based projects (Documentation, Tools, gopls)
#37203 testing: parallel subtest log output not properly constrained in go1.14rc1 (NeedsInvestigation)
#37201 runtime: TestCgoPprofPIE is flaky (NeedsInvestigation)
#37198 go.dev: Examples title is not generated, anchor link to examples is not working (NeedsFix, go.dev)
#37197 cmd/go: go list should not add a dependency to go.mod (NeedsInvestigation, WaitingForInfo, modules)
#37196 time: a Timer should not send to its channel after its Stop method returns (NeedsDecision, early-in-cycle)
Issueの詳細を表示
gh issue viewにイシュー番号を指定すると、対象のイシューのページをブラウザで開くことができます。
$ gh issue view <number>
例)
$ gh issue view 37235
Opening https://github.com/golang/go/issues/37235 in your browser.