25

I've read several other 'git hangs on clone' questions, but none match my environment and details. I'm using git built under cygwin (msys git is not an option) to clone a repo from a Linux host over SSH.

git clone user@host:repo

I've tested against the same host on other platforms, and it works fine, but on this Windows machine the clone hangs indefinitely. I set GIT_TRACE=1 and it looks like the problem is with this command:

'ssh' 'user@host' 'git-upload-pack '\''repo'\'''

My SSH keys are set up correctly: ssh user@host works fine. When I run the command, I get a bunch of output that ends like this:

...
003dbbd3db63763922ad75bbeefa3811dce001576851 refs/tags/start
0000

Then it hangs for 20+ minutes, which is the longest I've waited before killing it.

The server has Git 1.7.11.7 with OpenSSH 5.9p1, while the client has Git 1.7.9 with OpenSSH 6.1p1.

Is that supposed to be the end of the git-upload-pack output? Is this a bug in Git or my configuration?

DNS
  • 37,249
  • 18
  • 95
  • 132
  • have you tried to copy a clone (from linux/mac) to the windows pc and "used" it? perhaps some git issues with windows (case insensitivity, character encoding, ...) is the reason, and this might help to track it down. – mnagel Jul 02 '13 at 13:57
  • 1
    This is expected from `git-upload-pack`. It is waiting for you (well, your git client) to do some negotiation where you request something, telling it what you *want* and what you *have*. You really cannot use any other git client for troubleshooting? – Edward Thomson Nov 06 '13 at 17:45
  • @EdwardThomson I no longer have access to that environment, but no, I did not have the option of using any other git client. Both server and client were compiled from source, so there shouldn't have been any differences in behavior except as introduced in platform-specific code and dependencies. – DNS Nov 07 '13 at 14:14
  • Note that my test of running the command by itself isn't necessarily valid. It's possible that the actual client stalled on that command for an entirely different reason. I just provided that info in case it was relevant. – DNS Nov 07 '13 at 14:19
  • When you use linux on the client side, you can use `strace` to find out which kernel calls the client issues. This can give a more detailed view about which part failed. – Rudi Nov 09 '13 at 09:25

6 Answers6

3

The upcoming git1.8.5 (Q4 2013) will document more the smart http protocol.
See commit 4c6fffe2ae3642fa4576c704e2eb443de1d0f8a1 by Shawn O. Pearce.

With that detailed documentation, the idea would be to monitor the web requests done between your git client and the server, and see if those conforms to what is documented below.

That could help in pinpointing where the service "hangs".


The file Documentation/technical/http-protocol.txt insists on:

  • the "Smart Service git-upload-pack"

    • Clients MUST first perform ref discovery with '$GIT_URL/info/refs?service=git-upload-pack'.

      C: POST $GIT_URL/git-upload-pack HTTP/1.0
      S: 200 OK
      S: Content-Type: application/x-git-upload-pack-result
      S: Cache-Control: no-cache
      S:
      S: ....ACK %s, continue
      S: ....NAK
      
    • Clients MUST NOT reuse or revalidate a cached reponse.

    • Servers MUST include sufficient Cache-Control headers to prevent caching of the response.
    • Servers SHOULD support all capabilities defined here.
    • Clients MUST send at least one 'want' command in the request body.
    • Clients MUST NOT reference an id in a 'want' command which did not appear in the response obtained through ref discovery unless the server advertises capability "allow-tip-sha1-in-want".
  • The "negociation" algorithm

    (c) Send one $GIT_URL/git-upload-pack request:
    C: 0032want <WANT #1>...............................
    
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

This worked for me, incase it helps someone else.

Check your git remote url. It might hang with git-upload-pack on a trace if your using the wrong url type. You change the url from ssh git@github.com: to https://github.com/ on your remote.

blamb
  • 4,220
  • 4
  • 32
  • 50
  • 1
    I bristle at calling `git@` the "wrong" url type, but this hack/workaround did eliminate the hang for me, so I am upvoting anyway. It seems like a misconfiguration on the hosting end (for me the host is bitbucket). – pestophagous Apr 13 '21 at 17:44
  • ooh, yeah, why did i even say that, ok, an unsupported one? haha. yeah, i prefer the git url too. – blamb May 04 '21 at 20:20
  • this fixed for me, but it makes me sad. – Erik Aronesty Jun 17 '22 at 17:24
1

We have faced a similar issue - and we attributed it to the following: Our git repo has a LOT of binary files checked in (multiple versions, over the past 1.5 years of this project). So, we assumed that this was the cause.

To support this theory, we have other code bases that are more recent (and thus do not have so many binary files and their versions) - which do not exhibit this behavior.

Our setup: Git setup on linux, site-to-site VPN between London and India over a T1 line.

Nikhil Gupta
  • 1,708
  • 1
  • 23
  • 38
  • 1
    My repo did have a lot of binary objects, but in my case the clone was over a gigabit local link. Cloning on other platforms (tested on Mac, Linux, Solaris) of the same repo took roughly a few minutes. So unless git on Windows is multiple orders of magnitude slower for some reason, which is not my experience using it elsewhere, the problem is probably not related to the repo size or contents. – DNS Nov 07 '13 at 14:22
  • i did confirm this happened to me on 2 machines, and never happened on linux. so it does seem windows related. also, for me at least, it only happens with very large/old repos – Erik Aronesty Jun 17 '22 at 17:25
1

I was having this same problem after I added some jazz like this to my ssh config in order to set window titles in tmux:

Host *
PermitLocalCommand yes
LocalCommand if [[ $TERM == screen* ]]; then printf "\033k%h\033\\"; fi

getting rid of that fixed my git.

1

An outdated PuTTy can also cause this. Your system might be using plink.exe as GIT_SSH.

You can install the latest development build from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html to make sure this is not the problem.

Oliver Salzburg
  • 21,652
  • 20
  • 93
  • 138
0

My problem was simple. I updated the VPN client and git started hanging. I quit the VPN client and restarted it.

Daniel
  • 3,243
  • 2
  • 32
  • 31