1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

git pushで自分のレポジトリへのアクセスが403で拒否された対処方法 remote: Permission to user1.git denied to user2

Posted at

はじめに

githubのアカウントを2つ持っているが、
pushした際にクローンしたレポジトリと違う方のユーザーが認識されてしまい、403エラーが返ってきた。

それぞれuser1やuser2は自分のものと比較して進めること。

問題

remote: remote: Permission to user1.git denied to user2
fatal: unable to access 'https://github.com/user1/~.git/': The requested URL returned error: 403

解決方法

gitconfigを確認する。

$ cat ~/.gitconfig
[user]
        email = email
        name = user2

nameがuser2となっている。
この場合、user1に切り替える。

$ git config --global user.name "user1"

再度pushする。
しかし、同じエラーとなってしまう。
調査していくうちにPC設定に問題があることが判明した。
コントロールパネル>(ユーザーアカウント)>資格情報マネージャー>Windows資格情報

githubの資格情報があったらそれを削除する。

image.png

完了したら再度pushする。

$ git push -u origin main

今度こそうまくいった。

おわりに

どこのuserかは気を付けよう

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?