---
lang: ja-jp
breaks: true
---
# Windows で GitHub CLI を使用する 2021-05-20
> GITHUB CLI
> https://cli.github.com/
> cli/cli
> https://github.com/cli/cli
## Windows版の Github CLI をダウンロードしてインストールする

## 確認
```shell=
>where gh
C:\Program Files (x86)\GitHub CLI\gh.exe
>gh version
gh version 1.10.2 (2021-05-19)
https://github.com/cli/cli/releases/tag/v1.10.2
```
:::info
インストーラ―を実行すれば、環境変数への登録も自動的に行われている。
登録されていない場合は、以下をPATHに追加する
`C:\Program Files (x86)\GitHub CLI\`
:::
## Github にログイン
### トークンでログインする場合
```shell=
>gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Paste an authentication token
Tip: you can generate a Personal Access Token here https://github.com/settings/tokens
The minimum required scopes are 'repo', 'read:org', 'workflow'.
? Paste your authentication token: ****************************************
- gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as xxxxx
```
### ブラウザでログインする場合
```shell=
>gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? 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: BBDF-CF78
Press Enter to open github.com in your browser...
✓ Authentication complete.
- gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as xxxxxxxx
```
:::info
`gh auth login`を実行してから数日後に、gitコマンドでリモートリポジトリにアクセス出来ない現象が発生したが、再度 `gh auth login` を実行することで正常にアクセスできるようになった。
:::
## Windows では、右クリックメニューで出てくる「git for windows」のシェルが便利


###### tags: `git` `GitHub CLI` `GitHub`