【Windows資格情報削除で解決】git-pushで403エラーが出る時の解決法

【Windows資格情報削除で解決】git pushで403エラーが出る時の解決法

訳があって普段使っているgithubアカウント以外のアカウントでリポジトリを作成し、そこにpushしようとしたらハマったので、解決法を簡単に書いておきます。

症状

git push origin masterを実行すると

remote: Permission to<username(new)>/<repositoryname>.git denied to <username(old)>.
fatal: unable to access 'https://github.com/<username(new)>/<repositoryname>.git/'
: The requested URL returned error: 403

と表示され、pushできない。

環境

  • windows10 Home
  • git version 2.21.0.windows.1

試したこと

  • git pushで403のエラーが返ってくる問題
    • git remote set-url origin https://<username(new)>@github.com/<username(new)>/<repositoryname>.git
      も試しましたが、結局元のアカウントからpushをしてしまいます。この方法では新しいアカウントのパスワードも聞かれず、前進なし。

解決法

ruddy12
Apr ’17
@MrsColombo I had this problem too but managed to solve it, the error is that ur computer has saved a git username and password so if you shift to another account the error 403 will appear. Below is the solution
For Windows you can find the keys here:

control panel > user accounts > credential manager > Windows credentials > Generic credentials

Next remove the Github keys.

日本語訳すると、

  1. コントロールパネルを開く
  2. ユーザーアカウントを開く
  3. 資格情報マネージャーを開く
  4. Windows資格情報の汎用資格情報内にあるgithub.comの情報を削除

この状態で再度pushしようとするとログイン画面が開かれるので、新しいアカウントでログインしてください。

これで無事push出来ました。

コメントする

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

Exit mobile version