1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

git pull時、キーチェーンアクセスからPATが適用されなくなった際の対応メモ

Posted at

何かの作業の影響で、普段キーチェーンアクセスに登録されているGithubのPersonal Access Tokenが読み込まれなくなってしまったので、その時の対応メモをまとめます。

事象

  • git pull コマンドを実行したところ、UsernamePassword が聞かれるようになってしまった

確認したこと

  • Githubのユーザー名とパスワードを入力したところ、エラーになった
  • Githubのユーザー名とPATを入力したところ、認証されpullが実行された
  • Macのキーチェーンアクセスのgithubの項目は残っていて、PATも保存されていた
  • 試しにGithubで既存と同様の権限を付与したPATを新規作成し、キーチェーンアクセスに登録しても事象は改善しなかった

原因

  • gitconfig からキーチェーンアクセス認証の項目が削除されていた

対処法

  • 設定されているかを確認
    • 以下の項目が出力されたら設定済
    • 今回のケースの場合、以下の設定が削除されていたため発生した
$ git config --list | grep credential.helper
credential.helper=osxkeychain
  • 設定されていない場合、以下のコマンドで設定を追加
$ git config --list | grep credential.helper
$ git config --global credential.helper osxkeychain
$ git config --list | grep credential.helper
credential.helper=osxkeychain

まとめ

この事象が発生する前に、Gitの設定をいじっていたのでどこかで誤って削除してしまったようでした。
普段できていることが突然できなくなるとちょっと焦りますよね。
設定ファイルをいじる際は気をつけようと思います。

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?