为什么这个 git clone 命令失败?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/999195/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why is this git clone command failing?
提问by Ethan
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.
尝试使用git clone
命令。我的理解(如有错误请更正)是,为了托管 Git 存储库,您只需要一台运行 ssh 的机器和位于其上允许位置的项目/存储库。
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.
我在运行 ssh 的 OS X 系统上有我的 git 存储库。我正在尝试在 Windows XP 系统上克隆它。我在 XP 机器上安装了 Git Bash。在 Git bash (MINGW) 控制台中,我可以 ssh 进入 Mac 没问题。
However, git clone
fails...
然而,git clone
失败...
$ 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
扩展名:
$ git clone username@host:~/project/path/contactdb
$ git clone username@host:~/project/path/contactdb.git
Do I need something else installed on the Mac?
我需要在 Mac 上安装其他东西吗?
回答by Jakub Nar?bski
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:
您需要在拥有要克隆的 Git 存储库的机器上安装 Git;git-upload-pack
执行 ssh 时,还必须在远程机器上的 $PATH 中。直接 ssh-ing 到远程机器时,您是否得到类似以下响应:
$ 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).
(当然,shell 的名称取决于远程端使用的是什么)。
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.
可能还有问题(尽管可能不是您的情况)是远程机器配置错误,因此使用交互式 shell 进行 ssh 连接,或者在连接时提供一些消息,或者设置交互式变量,如臭名昭著的 $CDPATH 环境变量。
回答by Mark Sprague
I solved the problem by adding the following line to my ~/.bashrc file of the remote computer:
我通过将以下行添加到远程计算机的 ~/.bashrc 文件中解决了该问题:
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.
问题是 $PATH 不包括非交互式会话的 /usr/local/git/bin 。添加到 ~/.bashrc 纠正了这个问题。
回答by Michael Willer
Another way would be to do:
另一种方法是这样做:
git clone --upload-pack /path/to/git-upload-pack ssh://user@host/~/project/path/contactdb
git clone --upload-pack /path/to/git-upload-pack ssh://user@host/~/project/path/contactdb
回答by AaronELBorg
I used
我用了
git clone mysite.net:/path/to/site
git clone mysite.net:/path/to/site
which worked for me.
这对我有用。
回答by whitefoxx
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.
我在 mac os 上遇到了同样的问题,我通过将 git-upload-pack 从 /usr/local/git/bin 复制到 /bin 解决了这个问题。
回答by marika.daboja
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
我遇到了同样的问题,并且没有删除过期的证书,它开始工作的所有悲伤。这次我唯一不同的是将WiFi从连接到代理网络切换到我的私人移动热点。然后我在终端中运行以下命令
$ git clone https://[email protected]/project-folder/project-name.git
Then it started cloning and requested password..
然后它开始克隆并请求密码..
Cloning into 'project-name'...
Password for 'https://[email protected]':
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.
回答by handle
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]
对于 msysgit,当路径包含空格时,使用 -u 选项提供 git-upload-pack 的路径不起作用,因为似乎不支持引号(单、双)(1.7.11.msysgit.1)。将它添加到我的 PATH 工作(C:\Program Files (x86)\Git\libexec\git-core)。[但是,我的设置还有其他问题]
回答by Shaun Wilson
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".
我尝试了所有方法,验证了我的密钥、路径和工具版本。尽管如此,我还是无法使用“git shell”、“git gui”和“tortoise git”从 github 克隆一个 repo。
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:
我下载并安装了“ Visual Studio Tools for Git”(需要“VS2012 Update 2 CTP”)并且能够从 Visual Studio 内部克隆 repo:
- 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"
- 点击“主菜单->查看->团队资源管理器”
- 点击“团队资源管理器->连接到团队项目”
- 点击“Team Explorer->Local Git Repositories Section->Clone”
- 输入要克隆的 Git Repo 的 URL(黄色框)
- 输入或浏览要克隆到的本地文件夹
- 点击“克隆”
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.
片刻之后,repo 被克隆。我已经通过这种方式成功克隆了六个 repo,其中 msysgit、github 和 tortoisegit 都未能按预期工作。
回答by milesmeow
If you're using SSH make sure you also have all the SSH keys setup correctly.
如果您使用 SSH,请确保您还正确设置了所有 SSH 密钥。