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

More than 1 year has passed since last update.

githubのパスワード変更後にpushすると"remote: Invalid username or password."とエラーが発生した

Last updated at Posted at 2022-09-05

はじめに

githubからpersonal access tokenの有効期限が近いですよ!とメールが来ていたのでメール内のリンクから新しくtokenを再生成しました。
再生成後にgithubへpushをしようとすると、下記エラー文が表示されてpushができなくなりました。

~ % git push origin ブランチ名
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/~

有効期限が近づいてtokenを再生成する度に発生するエラーですが、数ヶ月後にまたpushできなくて一瞬ビビる将来の自分が容易に想像できるので、エラーの対応をqiitaに備忘録として残します。

対応

下記のようにターミナルでgitの名前を再設定します。

git config --global user.name ユーザ名
#ユーザー名はgithubのユーザー名です

そうすると、次回のpush時にユーザー名とパスワード(再生成した際に表示された文字列)を入力すればpushできるようになります。

~ % git push origin ブランチ名
Username for 'https://github.com': ユーザー名
Password for 'https://ユーザー名@github.com': パスワード(セキュリティのため文字を打ち込んでも表示されないようになってます)

こんなに簡単な手順でも毎回急にpushできないのは初学者の自分としてはビビります。

それにしても名前は変更してなくてpasswordが変わってるのになぜ名前を再設定しないといけないのだろうか。。
git config関連も勉強してみよう。

参考

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