26

Trying to use the git clone command. My understanding (please correct if wrong) was that in order to host a Git repository you just need a machine running ssh and the project/repository sitting on it in a permitted location.

I have my git repository on an OS X system that's running ssh. I'm trying to clone it on a Windows XP system. I have Git Bash installed on the XP machine. In the Git bash (MINGW) console, I can ssh into the Mac no problem.

However, git clone fails...

$ git clone username@host:~/project/path/contactdb
Initialized empty Git repository in 
  c:/Documents and Settings/Administrator/My Documents/projects/contactdb/.git/
bash: git-upload-pack: command not found
fatal: The remote end hung up unexpectedly

Tried it with and without .git extension:

$ git clone username@host:~/project/path/contactdb

$ git clone username@host:~/project/path/contactdb.git

Do I need something else installed on the Mac?

Ethan
  • 57,819
  • 63
  • 187
  • 237

9 Answers9

21

You need to have Git installed on the machine that has Git repository you want to clone; also git-upload-pack has to be in $PATH on remote machine when doing ssh. Do you get something like the following response when directly ssh-ing to remote machine:

$ ssh username@host git-upload-pack --help
usage: git upload-pack [--strict] [--timeout=nn] <dir>

or the following (wrong) response:

$ ssh username@host git-upload-pack --help
bash: git-upload-pack: command not found

(of course name of shell depends on what remote side is using).

What also might be problem (although perhaps not in your case) is having misconfigured remote machine so that uses interactive shell for ssh connection, either giving some messages on connection, or setting interactive variables like infamous $CDPATH environmental variable.

Jakub Narębski
  • 309,089
  • 65
  • 217
  • 230
7

I solved the problem by adding the following line to my ~/.bashrc file of the remote computer:

export PATH=$PATH:"/usr/local/bin:/usr/local/git/bin"

The problem was that $PATH did not include /usr/local/git/bin for non-interactive sessions. The addition to ~/.bashrc corrected that problem.

Mark Sprague
  • 71
  • 1
  • 1
4

Another way would be to do:

git clone --upload-pack /path/to/git-upload-pack ssh://user@host/~/project/path/contactdb

Roberto Tyley
  • 24,513
  • 11
  • 72
  • 101
3

I used

git clone mysite.net:/path/to/site

which worked for me.

Liam McInroy
  • 4,339
  • 5
  • 32
  • 53
2

I had the same problem on mac os, and I solved this by copy the git-upload-pack from /usr/local/git/bin to /bin.

whitefoxx
  • 41
  • 5
  • 1
    That's not fixing the issue, he needs to add PATH to his environment. Why move binaries around? – sdot257 Aug 28 '10 at 12:15
  • It's already included in the PATH, and still has the problem, I don't know why, so I moved it to the bin and it works. Maybe you are right, but that was exactly how i solved this in my computer. – whitefoxx Aug 29 '10 at 13:53
1

I have had same problem and without removing expired certificate all of the sadden it started working. The only thing I did differently this time was to switch WiFi from been connected to the proxy network to my private mobile hot spot. Then I run below command in the Terminal

$ git clone https://my-login@bitbucket.org/project-folder/project-name.git

Then it started cloning and requested password..

Cloning into 'project-name'...
Password for 'https://my-login@bitbucket.org':

Repository has been downloaded..

remote: Counting objects: 2449, done.
remote: Compressing objects: 100% (1244/1244), done.
remote: Total 2449 (delta 1388), reused 1999 (delta 1070)
Receiving objects: 100% (2449/2449), 768.56 KiB | 101.00 KiB/s, done.
Resolving deltas: 100% (1388/1388), done.
marika.daboja
  • 881
  • 13
  • 27
0

For msysgit, using the -u option to supply the path to git-upload-pack does not work when the path includes spaces because quotes (single, double) seem not to be supported (1.7.11.msysgit.1). Adding it to my PATH worked (C:\Program Files (x86)\Git\libexec\git-core). [However, I have additional problems with my setup]

handle
  • 5,859
  • 3
  • 54
  • 82
0

I tried everything, I verified my keys, paths and tools versions. Still, I was unable to clone a repo from github using "git shell" "git gui" and "tortoise git".

I downloaded and installed "Visual Studio Tools for Git" (which required "VS2012 Update 2 CTP") and was able to clone the repo from inside Visual Studio:

  • Click "Main Menu->View->Team Explorer"
  • Click "Team Explorer->Connect To Team Projects"
  • Click "Team Explorer->Local Git Repositories Section->Clone"
  • Enter URL of Git Repo to Clone (yellow box)
  • Enter or Browse for Local Folder to Clone into
  • Click "Clone"

After a moment, the repo was cloned. I've successfully cloned a half dozen repo's this way where msysgit, github and tortoisegit all failed to work as expected.

Shaun Wilson
  • 8,727
  • 3
  • 50
  • 48
0

If you're using SSH make sure you also have all the SSH keys setup correctly.

http://help.github.com/mac-set-up-git/

milesmeow
  • 3,688
  • 5
  • 35
  • 58