I recently had to debug an issue where the Git client refused to connect to an http url to fetch content, but worked well on the https url. I was curious to find out what was happening under the hood. It turned out that the http end point was configured to redirect to https url and the Git client (1.7.1) that was under test failed to honor the redirect request. I had googled to find out about GIT_CURL_VERBOSE and decided to search the Git source for more of these. I am sharing here few tips to debug and fix http(s) related issues in Git client (Git for linux/msysgit for windows), which I feel can be useful in debugging or fixing remote http(s) helper.
GIT_CURL_VERBOSE – Set this environmental variable to a Boolean value to debug the curl transaction while accessing the repository via http(s) remote helper
GIT_CURL_VERBOSE=1 git ls-remote https://github.com/git/git.git
-Troubleshooting curl related issues
GIT_SSL_NO_VERIFY – Set this environmental variable to a Boolean value to disable the SSL certificate verification while accessing the repository via https remote helper
GIT_SSL_NO_VERIFY=1 git ls-remote https://18.104.22.168/git/git.git
(github.com resolved to 22.214.171.124 on 13/03/2013)
-Self Signed SSL Certificates.
-Internal CA certificate in an corporate environment
GIT_HTTP_LOW_SPEED_LIMIT – Set this environmental variable to a value greater than zero, representing the download speed in bytes per second.
GIT_HTTP_LOW_SPEED_TIME – Set this environmental variable to a value greater than zero, representing the time in seconds.
When these two environmental variables are set to values more than zero, the git remote operations over http(s) remote helper will terminate if the download speed maintains at or below
GIT_HTTP_LOW_SPEED_LIMIT bytes per second for GIT_HTTP_LOW_SPEED_LIMIT second(s)
GIT_HTTP_LOW_SPEED_LIMIT=2000 GIT_HTTP_LOW_SPEED_TIME=5 git clone
(To simulate the network speed one can use trickle on linux)
-To include in scripts that should not be locked for a long duration because of a slow network connectivity.
GIT_HTTP_USER_AGENT – Set this environmental variable to the string that would be presented to the server as the User-Agent string, when accessing the repository via http(s) remote helper
GIT_HTTP_USER_AGENT=CustomAgent/1.0 GIT_CURL_VERBOSE=1 git ls-remote https://github.com/git/git.git
-If there are proxies that limits the internet connectivity based on the User-Agent string, this environmental variable can be set to a browser User-Agent string that is accepted by the proxy.