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?

GitHub の error: RPC failed; HTTP 400 curl 22 への対処法

Posted at

0. はじめに

GitHub の https://github.com/Krypf/krphysics に対して git push ができなくなった.
なにをどうやっても fatal が出る.
なにも push できなくなった.

git push できていたリポジトリもあったので放置していたところ,GPT 君が突如正解を叩き出し解決することができた.

結論から言うと push を溜め込んだためにファイルサイズがでかくなりすぎたので,設定を変えたらいいということらしい.

git config --global http.postBuffer 157286400

↑ だいたい 150 MB ですがいわゆる メビバイトという単位です.GPT 君によると 150 MB ですが正確には多分違います.

push できました.

1. git push ができない

git commit までは できるが,git push するとエラーを吐く.

Enumerating objects: 51, done.
Counting objects: 100% (51/51), done.
Delta compression using up to 8 threads
Compressing objects: 100% (40/40), done.
error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (41/41), 1.30 MiB | 2.05 MiB/s, done.
Total 41 (delta 20), reused 0 (delta 0), pack-reused 0
fatal: the remote end hung up unexpectedly
Everything up-to-**date**

ほんとに何もできない.困っちゃう・・・

新しい token を作成したが進まなかった.

こいつ → https://github.com/settings/personal-access-tokens

ちょうど expire の時期が過ぎたことは把握していたので,原因の特定がそれに引きずられて遅くなった.

2. 送信できるファイルサイズを大きくする

git commit の履歴が 2 months ago (January 7, 2025 at 1:30 AM) から溜まっており,悪い癖である先送りという怠惰が邪魔をして 2ヶ月以上困っていたことが分かった.

GPT 君および Google 先生と数十の問答を繰り返し諦めかけていたところ,突如として GPT 君がやる気を出し違った解答を提示してきた.

上のエラーを GPT 君にインプットする
Still failed: % git push origin main                                                          
Enumerating objects: 51, done.
Counting objects: 100% (51/51), done.
Delta compression using up to 8 threads
Compressing objects: 100% (40/40), done.
error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (41/41), 1.30 MiB | 1.95 MiB/s, done.
Total 41 (delta 20), reused 0 (delta 0), pack-reused 0
fatal: the remote end hung up unexpectedly
Everything up-to-date

答え

The error you're seeing (RPC failed; HTTP 400 curl 22 The requested URL returned error: 400) often happens due to large push sizes or network issues. To resolve this:

  1. Increase the HTTP buffer size:
    Run this command to allow larger file pushes:

    git config --global http.postBuffer 157286400
    
  2. Use SSH instead of HTTPS:
    Set up SSH authentication, which avoids issues with tokens:

    git remote set-url origin git@github.com:<USERNAME>/<REPO>.git
    

Try these fixes and see if the issue resolves!


2 番ばっかりやっていたが,唐突に違う方法が提示されている(?)

なるほど,言われた通りやってみよう.怖いので先に git config --get http.postBuffer で値をチェックしてみたところデフォルトだと 1 MB で空行が返ってくるらしいが,それもその通りになっている (デフォルトの値は出てきませんでした).

満を持して肩透かしを食らって 1 番の git config --global http.postBuffer 157286400 を入力したところ,一瞬で終わりました.

めでたく push 完了
% git push origin main                                   
Enumerating objects: 55, done.
Counting objects: 100% (55/55), done.
Delta compression using up to 8 threads
Compressing objects: 100% (44/44), done.
Writing objects: 100% (45/45), 1.30 MiB | 7.97 MiB/s, done.
Total 45 (delta 22), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (22/22), completed with 6 local objects.
To https://github.com/Krypf/krphysics.git
   f1ddfb1..ca291bd  main -> main

3. おまけ:Manager とやらをインストール

おまけに GitHub の Personal Access Token (PAT) を使う新しい方法を書いておきます.
とりあえず git-credential-manager というものをインストールした (macOS 14).

git-ecosystem/git-credential-manager: Secure, cross-platform Git credential storage with authentication to GitHub, Azure Repos, and other popular Git hosting services.
https://github.com/git-ecosystem/git-credential-manager?tab=readme-ov-file

==> Installing Cask git-credential-manager
==> Running installer for git-credential-manager with sudo; the password may be necessary.
Password:
installer: Package name is Git Credential Manager
installer: Installing at base path /
installer: The install was successful.
🍺  git-credential-manager was successfully installed!
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

できた.

あとは公式の fine-grained personal access token の作成 に従います.

n. おわりに

めんどくさくて放置していてめげずに取り組み続け2ヶ月かかりましたが,エラーメッセージのとおり蓋を開けてみればパケットの送信の問題だった.

終わってみればあっけなかったが,定期的にこまめに git push するようにします.

RPC failed; HTTP 400 curl 22 で検索すると過去の記事もヒットしました.

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?