If you’ve encountered the error:

[info] error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400

Typically this occurs due to large file sizes being pushed to a remote repository, leading to an issue with the buffer size Git uses for HTTP operations. This turned up recently on macOS; I have no idea why or what changed in my repo.

Solution: Increasing the Post Buffer Size

To resolve this problem, increase Git’s HTTP buffer size using the http.postBuffer configuration. You can do this with the following command:

git config --global http.postBuffer 157286400

Why This Works

By default, Git’s buffer for HTTP operations is quite small. When pushing large files or numerous files simultaneously, the buffer can become overwhelmed, leading to the HTTP 400 error. Increasing the buffer size to 157286400 (approximately 150 MB) allows Git to handle larger payloads without running into this limitation. The above command increases the buffer size for all repositories on your system.

Verify the configuration by running:

git config --global --get http.postBuffer

Retry your Git push to see if the issue is resolved. If the error persists after increasing the buffer size, you may want to look into other potential issues, such as network problems or repository limits.