Help us understand the problem. What is going on with this article?

gitでpushしようとしたら403された話

More than 3 years have passed since last update.

新しくgitのアカウントを作り、ローカルでゴニョゴニョして、addしてcommitしてpushしたら↓のようなエラーが・・

$ git push origin master
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/hogehoge/rss.git/info/refs

fatal: HTTP request failed

ここまでどうやったか

一応手順が間違ってなかったことを確認するために、
ここまでどうやって来たかをまとめて起きます。

A. githubでリポジトリ作成

最初にgithubでリポジトリを作りました。

B. ユーザ名登録

$ git config --global user.name "hogehoge"
$ git config --global user.email hogehoge@example.com

C. リポジトリの登録

$ git remote add https://github.com/hogehoge/rss.git
# 今回はrssという名前のリポジトリを作りました

D. sshキーの登録

(ローカルにて)
$ ssh-keygen -t rsa

これで、~/.ssh/id_rsa.pubをgithubに登録

E. いざPush!

$ git push origin master
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/hogehoge/rss.git/info/refs

fatal: HTTP request failed

おぉ・・・

解決策

リモートのURLにユーザ名を含めてあげる必要があるそうです。

$ git remote set-url origin https://hogehoge@github.com/ritukiii/rss.git

これで、git configでremoteのURLが変わったことを確認して変わってればOK.

もう一度挑戦!!

pushしたらパスワード聞かれて無事に成功!

$ git push origin master
Password: 
Counting objects: 132, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (114/114), done.
Writing objects: 100% (132/132), 808.06 KiB, done.
Total 132 (delta 7), reused 0 (delta 0)
To https://hogehoge@github.com/ritukiii/rss.git
 * [new branch]      master -> master
ritukiii
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした