RPC failed Error 502 running git commands

Problem

Running git commands like git push to a Cloud Source Repository (CSR) fails with the following error: 

error: RPC failed; HTTP 502 curl 22 The requested URL returned error: 502

Git operations involving single files or very small files (few KBs) might succeed, but larger operations fail.

Environment

  • Client (such as a local machine, Virtual Machine, etc.)
  • Remote Cloud Source Repository

Solution

  1. Set your http.version to HTTP/1.1 by runnning this command:
    $ git config --global http.version HTTP/1.1
  2. To persist this setting over sessions, create or update your .git/config file to contain this setting.

Cause

At this point in time, CSR does not support communication over HTTP/2.