LoginSignup
0
0

More than 5 years have passed since last update.

【備忘録】git pushに失敗した時の解消法

Last updated at Posted at 2019-07-06

はじめに

Androidで新規のプロジェクトを作成した際に、git pushすると以下エラーで失敗してしまいました。

The requested URL returned error: 403

毎回、「これどうやって解決するんだったっけ・・・」と思い出すのが面倒臭かったので、備忘録として自分が行なっている解決方法をここに残すことにしました。(根本的な解決になっているかは微妙ですが・・・)

なので、ここで記載するのは「git pushで生じる全てのエラーに対する解消法」ではなく、403エラーについて記載します。

現象

上で説明した通りだが、git pushしようとすると、以下のエラーが発生しました。

Push failed: Failed with error: unable to access 'https://github.com/user_name/repository_name.git/': The requested URL returned error: 403

解決法

上述のエラーが発生した際に、自分が解決するために行なっていることを記載します。
403エラーを解決する方法は、「gitのremoteのurlにユーザー名を含める」です。
方法としては、以下を入力します。

$ git remote set-url origin https://user_name@github.com/user_name/repository_name.git

⬇︎⬇︎⬇︎具体例⬇︎⬇︎⬇︎

内容
ユーザー名 taa-suuuk
リポジトリ名 TaaSuuukApp

gitのユーザー名とリポジトリ名が上の場合は、以下のようにurlを変更すれば解決します。

$ git remote set-url origin https://taa-suuk@github.com/taa-suuuk/TaaSuukApp.git

終わりに

git pushする際に403エラーが出た際の解決法でした。
以上、備忘録でした。(拙い文章だとは思いますが、備忘録なのでご容赦ください)

0
0
2

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