🔐
GitHubの認証情報が重複する@windows git
状況
VSCodeのソース管理からGitHubのPrivateリポジトリに接続すると画像のようなアカウントを選択するダイアログが表示される。
ダイアログ中のリンクにある説明の通りgithubのログイン情報を見ると確かに二つある。
❯ git credential-manager github list
enven-omiomi
enven-omiomi
git credential-manager github logout enven-omiomi
を2回実行して消しても復活する。
環境
❯ git --version
git version 2.41.0.windows.3
先にまとめ
-
git config --global --unset-all credential.helper
で余計なcredential.helperを消す - windowsの資格情報マネージャーから2つあるgithub.comの資格情報のうち一つを消す
-
git credential-manager github logout {user名}
を実行してログインしてない状態にする - ログインを求められたらログイン
解決策の詳細
credential.helperが2つ登録されているのが問題?のようなので1つにする。
❯ git config --show-origin --get-all credential.helper
file:C:/Program Files/Git/etc/gitconfig manager
file:C:/Users/enven/.gitconfig wincred
❯ git config --global --unset-all credential.helper
❯ git config --show-origin --get-all credential.helper
file:C:/Program Files/Git/etc/gitconfig manager
credential.helperは一つになったが、その後再度VSCodeからfetchするとアカウント選択ダイアログがでた。
ダイアログがでてもhelperは増えてない。一つのまま。
Windowsの資格情報マネージャーの情報が残っているのが現任らしいのでこちらの情報も消す必要がある。
Additionally, I had to open the Windows Credential Manager and delete the GitHub credential. When calling git fetch I had to re-enter the personal access token. But now I'm all set.
資格情報マネージャーを開くとgithubの資格情報が二つある。git:https://{user名}@github.com
とgit:https://github.com
。ユーザー名の入ってないほうを消す。
その後git credential-manager github logout {user名}
を実行してgit credential-manager github list
に何も表示されないようにする。
Discussion