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:
-
Increase the HTTP buffer size:
Run this command to allow larger file pushes:git config --global http.postBuffer 157286400
-
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 で検索すると過去の記事もヒットしました.
- Gitでpushすると400エラーが出た #error - Qiita https://qiita.com/bearl27/items/b768b28eb86fef0b9b5d
- gh repo clone / git clone で error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400が出る #Git - Qiita https://qiita.com/nakamasato/items/c27354d64a80cc612594
- git push failure while pushing a large respository of code - Stack Overflow https://stackoverflow.com/questions/62753648/git-push-failure-while-pushing-a-large-respository-of-code
- 【備忘録】Git - push時のエラーの解消 https://zenn.dev/hiro8_hiro8/articles/d63b3bfbe2c86e
- Git Push 時のエラー
RPC failed; HTTP 400
の原因と対処法 https://zenn.dev/ka_projects/articles/fb4de220a5ad71