Just Wanted to share a tip thats useful to debug, long running Git Commands or Git Commands that seem to be hanged for some reason,

Git has an in-built functionality for us to peek into what is running behind the scenes of a git command, just add GIT_TRACE=1 before ANY git command to get additional info, for example:

Other Flags that we can use are : GIT_CURL_VERBOSE=1, -v or –verbose

[server@user sp-server-branches]$ GIT_TRACE=1 git clone ssh://git.server.company.com/home/git/repositories/repo.git
trace: built-in: git ‘clone’ ‘ssh://git.server.company.com/home/git/repositories/repo.git’
Initialized empty Git repository in /home/mnbuild/krishna/sp-server-branches/repo/.git/
trace: run_command: ‘ssh’ ‘git.server.company.com’ ‘git-upload-pack ‘\”/home/git/repositories/modeln56.git’\”’
trace: run_command: ‘index-pack’ ‘–stdin’ ‘-v’ ‘–fix-thin’ ‘–keep=fetch-pack 403 on hostname.company.com’
trace: exec: ‘git’ ‘index-pack’ ‘–stdin’ ‘-v’ ‘–fix-thin’ ‘–keep=fetch-pack 403 on hostname.company.com’
trace: built-in: git ‘index-pack’ ‘–stdin’ ‘-v’ ‘–fix-thin’ ‘–keep=fetch-pack 403 on hostname.company.com’
remote: Counting objects: 398918, done.
remote: Compressing objects: 100% (114446/114446), done.
remote: Total 398918 (delta 262071), reused 392474 (delta 256979)
Receiving objects: 100% (398918/398918), 1.81 GiB | 30.14 MiB/s, done.
Resolving deltas: 100% (262071/262071), done.

Now, if the Above command is hangs,  I can easily distinguish a SSH Keys or Network Issue(see Upload Pack Commands above)

Cheers

Krishna.