ビットの海

ゆるふわソフトウェアエンジニアしゃぜのブログ

Mac で GitHub CLI セットアップのメモ

たまにしかやらなくて忘れるので

install

$ brew install gh

auth

$ brew auth login

なんかいろいろ聞かれる

$ gh auth login
? Where do you use GitHub? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: xxxx-xxxx
Press Enter to open https://github.com/login/device in your browser...
✓ Authentication complete.
- gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as shase

以下のようなデバイス認証に飛ばされるので、画面に従ってぽちぽちする

check

セットアップできると、gh コマンドが使えるようになる

$ gh repo list

Showing 17 of 17 repositories in @shase

NAME                                 DESCRIPTION                                    INFO          UPDATED
shase/profile                                                                       public        about 10 months ago
shase/terraform-gcp-sample                                                          private       about 1 year ago
shase/github-actions-sample                                                         public        about 2 years ago

...