ノート:
- If you use GitHub CLI to authenticate to GitHub Enterprise Server on the command line, you can skip generating a personal access token and authenticate via the web browser instead. For more information about authenticating with GitHub CLI, see
gh auth login. - Git Credential Manager is a secure, cross-platform alternative to using personal access tokens (PATs) and eliminates the need to manage PAT scope and expiration. For installation instructions, see Download and install in the GitCredentialManager/git-credential-manager repository.
個人アクセストークン(PAT)は、GitHub API またはコマンドラインを使用するときに GitHub Enterprise Server への認証でパスワードの代わりに使用できます。
A token with no assigned scopes can only access public information. トークンを使用してコマンドラインからリポジトリにアクセスするには、[repo] を選択します。 For more information, see "Available scopes".
トークンの作成
-
任意のページの右上で、プロフィール画像をクリックし、続いてSettings(設定)をクリックしてく� さい。
![ユーザバーの [Settings(設定)] アイコン](https://github.github.com/docs-ghes-3.1/assets/cb-34573/images/help/settings/userbar-account-settings.png)
-
左サイドバーで [Developer settings] をクリックします。

-
左のサイドバーでPersonal access tokens(個人アクセストークン)をクリックしてく� さい。

-
[Generate new token] をクリックします。
![[Generate new token] ボタン](https://github.github.com/docs-ghes-3.1/assets/cb-6922/images/help/settings/generate_new_token.png)
-
トークンにわかりやすい名前を付けます。

-
このトークンに付与するスコープ、すなわち権限を選択します。 トークンを使用してコマンドラインからリポジトリにアクセスするには、[repo] を選択します。

-
[Generate token] をクリックします。
![[Generate token] ボタン](https://github.github.com/docs-ghes-3.1/assets/cb-10912/images/help/settings/generate_token.png)

警告: トークンはパスワードのように扱い、秘密にしてく� さい。 API を操作する� �合は、トークンをプログラ� にハードコーディングするのではなく、環境変数として使用してく� さい。
コマンドラインでトークンを使用する
トークンを入手したなら、HTTPS経由でGitの操作をする際にパスワードの代わりにそのトークンを入力できます。
たとえば、コマンドラインでは以下のように入力できます。
$ git clone https://hostname/username/repo.git Username: your_username Password: your_token 個人アクセストークンは HTTPS Git 操作� けにしか使用できません。 SSH リモート URL を使用するリポジトリの� �合、リモートを SSH から HTTPS に切り替える必要があります。
ユーザ名とパスワードの入力を求められない� �合、資� �情� �がコンピュータにキャッシュされている可能性があります。 古いパスワードをトークンに交換するようキーチェーンで資� �情� �を更新できます。
Instead of manually entering your PAT for every HTTPS Git operation, you can cache your PAT with a Git client. Git will temporarily store your credentials in memory until an expiry interval has passed. You can also store the token in a plain text file that Git can read before every request. 詳細は「Git に GitHub の認証情� �をキャッシュする」を参照してく� さい。