Git verbose connection diagnostics

Git can use multiple transport protocols. We focus here on diagnosing connection issues for two commonly used Git transfer protocols: SSH and HTTPS.

Regardless of protocol used, Git trace capability can give more details. For example, before the problem commands, type:

  • Windows: set GIT_TRACE=1
  • MacOS / Linux: export GIT_TRACE=1

Git over HTTPS

Git clone over HTTPS can hang for a minute or more. Git clone from Overleaf will hang while other collaborators are making edits via the Overleaf web browser editor. Overleaf uses Git over HTTPS, and when Overleaf is busy (say, near federal grant deadlines) Git operations can be significantly slower on Overleaf. The verbose options of Git don’t add much information for Git over HTTPS connections, just a single additional line is added by --verbose like:

POST git-upload-pack (150 bytes)

HTTPS timeout

Git over HTTPS can have a timeout set like:

git config --global http.lowSpeedLimit 1000
git config --global http.lowSpeedTime 10

This means that connections of less than 1 kB / sec for 10 seconds will be dropped. This avoids endless hangs, but could cause marginal connections to fail, so adjust parameters based on your connection and server if needed.

Git over SSH

Git over SSH verbosity can be added on a per-command basis starting with:

git -c core.sshCommand="ssh -v"

This is quite verbose, so we usually wouldn’t add this to the .git/config file.

SSH timeout

Git over SSH timeouts can be addressed via SSH settings.

references

GitLab Git troubleshooting connection tips