How do I prevent timeouts when I push large changes to git?

When I push large changes to git (or sometimes clone from git) it fails with

error: RPC failed; result=22, HTTP code = 502

For example:

git push origin master
Counting objects: 1107, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (357/357), done.
Writing objects: 100% (1107/1107), 24.00 MiB | 682.00 KiB/s, done.
Total 1107 (delta 745), reused 1107 (delta 745)
error: RPC failed; result=22, HTTP code = 502
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

Does this help? (could potentially be other problems)

Increase the Git buffer size to the largest individual file size of your repo:
git config --global http.postBuffer 157286400

I have not seen this, even when cloning afwdata. Are you seeing this with a particular git server, or multiples?

If just one server, then which one? If it is Stash then this may be relevant: https://confluence.atlassian.com/display/STASHKB/Git+SSH+push+timeout+on+large+changes

If you see it with multiple servers then I suggest you examine your ~/.gitconfig for signs of a timeout. But that seems most unlikely.