GitHub CLI
このページでは GitHub CLI のインストール,設定,使い方をまとめます.
インストール
下記のコマンドでインストールします.
- Arch
- Ubuntu
sudo pacman -S github-cli
Ubuntu の場合は apt から直接インストールできないので,snap 経由でインストールします.
sudo apt install snapd
sudo snap install gh
設定
次のコマンドを実行することでアカウントの認証ができます.
gh auth login
ステップごとにガイドが表示されるので環境に合わせて選択すれば認証できます.
? What account do you want to log into? [Use arrows to move, type to filter]
> GitHub.com
GitHub Enterprise Server
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? [Use arrows to move, type to filter]
HTTPS
> SSH
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? SSH
? Upload your SSH public key to your GitHub account? [Use arrows to move, type to filter]
> /home/user/.ssh/id_ed25519.pub
Skip
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? SSH
? Upload your SSH public key to your GitHub account? /home/user/.ssh/id_ed25519.pub
? How would you like to authenticate GitHub CLI? [Use arrows to move, type to filter]
> Login with a web browser
Paste an authentication token
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? SSH
? Upload your SSH public key to your GitHub account? /home/user/.ssh/id_ed25519.pub
? How would you like to authenticate GitHub CLI? Login with a web browser
! First copy your one-time code: 51E6-B724
- Press Enter to open github.com in your browser...
使い方
リポジトリ作成
GitHub に新しいリポジトリを追加したいときは,ブラウザから GUI で作成するか,gh を下記のように使います.
gh repo create <repo-name> <visibility>
例:github-test という名前のプライベートリポジトリを作成する
gh repo create github-test --private
例:github-test という名前のパブリックリポジトリを作成する
gh repo create github-test --public