GitHub CLI
https://cli.github.com/
GitHubのCLIツール
インストールと初期設定
code:terminal
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
gh auth login
? What account do you want to log into? 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? Paste an authentication token
? Paste your authentication token: *********************************************************************************************
HTTPとSSHを選べるのなんで?
https://github.com/cli/cli/discussions/5532
https://github.com/settings/tokens で Personal Access Token をつくってね
自動補完もしようね
code:.zshrc
eval "$(gh completion -s zsh)"
reference.icon GitHub CLIで始める快適GitHub生活 #Git - Qiita
gh repo create my-repo
ChatGPT.icon
table:flags
フラグ 説明
--public 公開リポジトリを作成
--private プライベートリポジトリを作成(デフォルト)
--clone 作成後にリポジトリをローカルにクローン
--source=./my-project 指定したフォルダの内容をリポジトリにプッシュ
--push --sourceを指定した場合、内容を初回コミットとしてプッシュ
--description "My new project" リポジトリの説明を追加
--team=my-team チームリポジトリの場合、チーム名を指定
--license=mit リポジトリにライセンスを追加
--homepage=https://~~ リポジトリの関連ホームページを指定
--template=username/template-repo 指定したテンプレートリポジトリから作成