LoginSignup
5
1

More than 1 year has passed since last update.

gitコマンド実行時にPasswordじゃなくてPersonal Access Tokenを使えと言われたら

Last updated at Posted at 2021-08-16

出力

$ git pull
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: unable to access 'https://github.com/team/repo.git/': The requested URL returned error: 403

GitHubの認証にPasswordじゃなくてPersonal Access Tokenを使えと言われています

やったこと

  1. github.com の認証情報の削除

    1. MacOSの場合はKeychain Accessの 種類: インターネットパスワード の項目を削除スクリーンショット 2021-08-16 10.27.48.png
    2. Windowsの場合は資格情報マネージャーから削除するみたいです cf. https://webbibouroku.com/Blog/Article/git-logout-win
  2. PAT (Personal Access Token) の生成

    1. GitHub > Settings > Developer settings > Personal access tokens
    2. Generate new token から任意の名称で作成します
    3. 権限は repo にだけ全振りして、有効期間は90日間としました スクリーンショット 2021-08-16 10.23.27.png
    4. 生成後、 ghp_ から始まるトークンが表示されるものを控えておきます(画面遷移すると表示されなくなります)
  3. GitHubのユーザー名とパスワードを更新する

    1. git pull 等の任意のgitコマンドを実行すると UsernamePassword を要求されます
    2. 以前はPasswordにGitHubへのログインパスワードを入力していたと思いますが、そこに今回生成したPATを入力します
    3. そのまま任意のgitコマンドが実行されれば成功です

メモ

github.com の認証情報の削除を、Keychain Accessからではなく、次のようにコマンドラインで全て unset する方法が出てきましたが私の場合は特に変化がありませんでした。

git config --global --unset user.name
git config --global --unset user.email
git config --global --unset credential.helper

# - or -

git config --global --unset-all
5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1