LoginSignup
131
74

More than 5 years have passed since last update.

GitHub へのアクセスで remote: Invalid username or password と言われたので、git remote set-url でリポジトリを指定した。

Posted at

Git のローカルリポジトリから push をしたらパスワードを求められて失敗しました。

git push origin master
Username for 'https://github.com': pugiemonn
Password for 'https://pugiemonn@github.com': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/pugiemonn/pugiemonn.com'

あらら、前はこんな表示が出なかったのにおかしいです😭

GitHub へのアクセスを確認

よくある ssh -T で GitHub へのアクセスを確認します。

ssh -T git@github.com
Hi pugiemonn! You've successfully authenticated, but GitHub does not provide shell access.

successfully authenticated と言われているのに、前述のアクセスはダメみたいです。

Git の設定を確認

リポジトリ設定を確認します。

git remote -v
origin  https://github.com/pugiemonn/pugiemonn.com (fetch)
origin  https://github.com/pugiemonn/pugiemonn.com (push)

ぱっと見は合っている気がしたのですがここを変えてみます。

remote set-url でリポジトリを上書きする

remote の設定を上書きします。

git remote set-url origin リポジトリ名

こんな書き方なので

git remote set-url origin git@github.com:pugiemonn/pugiemonn.com.git

再び push

push ができるかを確認します。

git push origin master
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (7/7), done.
略

成功😇

Git の設定を確認

git remote -v 
origin  git@github.com:pugiemonn/pugiemonn.com.git (fetch)
origin  git@github.com:pugiemonn/pugiemonn.com.git (push)

書き換わっています。remote の設定がよくなかったみたいです。

REF

git - GitHub: invalid username or password - Stack Overflow

131
74
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
131
74