LoginSignup
10
8

More than 5 years have passed since last update.

githubへgit pushすると403エラーとなる時の対応

Last updated at Posted at 2017-08-14

githubへgit pushしようとしたところ403エラーでできなかったため、その解決方法のメモ書き。

現象

github desktopでリモートレポジトリにpublish(=初回のpush)しようとしたら正しく認証情報を登録しているにも関わらず、認証に関するエラーが出てpublishできなかった。
そこでコマンドライン上でgit pushしてみたところ、以下のようなエラーメッセージが出力された。

出力されたエラーメッセージ
$ git push
remote: Permission to AAA/abc.git denied to BBB.
fatal: unable to access '(リポジトリURL)': The requested URL returned error: 403

BBBユーザ情報はもう不要なので削除方法を調べたところ、
http://qiita.com/piyomarudayo/items/ae8b040080f53e9952ee
を見つけ、この資料に従ってgit credential fillやgit credential rejectしたが反応が返ってこない…
.git/configにも特にユーザ情報の記載なし。
なお端末はMacBookPro(MacOS 10.12.6 Sierra)

原因

  • エラーメッセージに書かれている通り、AAAユーザのリポジトリなのにBBBユーザの情報で認証しようとしているため。

対応方針

  • BBBユーザ情報は過去に使っていただけなので削除する。

解決方法

  • Macのアプリケーション→ユーティリティ内にある「キーチェーンアクセス」を起動して、github.comの項目から BBB アカウントの情報を削除する。

まとめ

  • .git/configに認証情報が書かれていない場合はgit credential fillコマンドによる確認が必要。
  • git credential fillやrejectを実行しても何も反応がない場合はキーチェーンアクセスを確認する。

参考資料

10
8
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
10
8