2
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 3 years have passed since last update.

gitにて、初回push時にエラー「Missing or invalid credentials.」となりpushできなかった話(解決までの流れも記載)

Posted at

記事概要

吾輩は猫である。
git練習中。
pushを行ったところ、下記エラーが出たため、解決を試みた。

結末としては、いろいろ触っていると解決できたので、エラー発生時の状況、エラー原因、調査・解決手順を残しておく。

エラー内容
Missing or invalid credentials.
Error: socket hang up
    at connResetException (internal/errors.js:570:14)
    at Socket.socketOnEnd (_http_client.js:440:23)
    at Socket.emit (events.js:228:7)
    at endReadableNT (_stream_readable.js:1185:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21) {
  code: 'ECONNRESET'
}

状況

環境はmacOS。
VScode上で初めてターミナルを起動し、
git add
→ git commit
→ git push
したところ、git pushした際に、冒頭のエラーが発生。
pushできず。

エラー内容

冒頭のエラーメッセージにおいて重要なのはおそらく下記の部分。

重要な部分(仮)
Missing or invalid credentials.

直訳すると「資格情報が無い、または無効」
んん、わからん。「資格情報」とは何を指しているのか。
後述するエラー原因調査を経ての推測だが、『資格情報』と言うのはユーザ名とパスワードのこと。

つまり、本エラーは「pushコマンドを実行しているお主は誰だ。名乗らぬ者はpushさせぬぞ」と言っておられる。

エラー原因調査・解決手順

まず、どこに原因があるのかを大きく切り分けることにした吾輩。
ずばり、原因はgit側かVSCode側かを探っていく。

と言うことで、VSCode上で行っていたgit pushを、普通にターミナルで行ってみることに。
これで、VSCode上のターミナルでpushした際のエラーが出れば、エラーの原因としてVSCodeのターミナルか通常のターミナルかといった違いは関係ないと言うことができると思ふ。

通常のターミナルでgit pushを行ったところ、ユーザ名とパスワードの入力を尋ねられた。
問われるがまま入力すると、push成功。

_:(´ཀ`」 ∠):{えぇ・・・

その後、VSCode上でgit add、git commitを再度行った上でgit pushしてみると、ユーザ名とパスワードを尋ねられ、問われるがまま入力。
pushできました。

_:(´ཀ`」 ∠):{えぇ・・・

と言うことで、pushできなかった要因は、push時にユーザ名とパスワードを入力しなかったからと思われる。
なぜ、初回のVSCodeターミナルでのpush時にユーザ名とパスワードを尋ねられなかったのか。
VSCodeの設定か、gitの設定か・・・結局、何の設定だったのかは分けられなかったけれど、エラー内容はわかった。
もう少し余力が出てきたら、そのあたりも調査してみます。

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