在 XCode 4 中使用 gitosis git 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5633371/
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
Using a gitosis git repository with XCode 4
提问by Pandafox
Hi I've been trying to access my git repository from XCode 4.
嗨,我一直在尝试从 XCode 4 访问我的 git 存储库。
Everything works just fine using the command line tools. I can clone my repo using:
使用命令行工具一切正常。我可以使用以下方法克隆我的 repo:
git clone [email protected]:somerepo.git
But in XCode, when trying to use:
但是在 XCode 中,尝试使用时:
ssh://[email protected]:somerepo.git
It just keeps asking me for a password, which I don't want to use at all.
它只是不断要求我输入密码,而我根本不想使用它。
The same thing happens with:
同样的事情发生在:
git://[email protected]:somerepo.git
Except that i also get a "Connection refused: unable to connect to a socket" error message.
除了我还收到“连接被拒绝:无法连接到套接字”错误消息。
Any idea how to solve this?
知道如何解决这个问题吗?
回答by herzbube
In Xcode 4.2, the following location string worked for me
在 Xcode 4.2 中,以下位置字符串对我有用
ssh://[email protected]:22/somerepo.git
The ssh://
part is required to tell Xcode which protocol should be used. Since the URL now contains a scheme, the port :22
specifier is also required to make Git happy. Withoutthe port, I got the following (weird) error message on the command line: "ssh: connect to host port 22: Connection refused".
该ssh://
部分需要告诉 Xcode 应该使用哪个协议。由于 URL 现在包含一个方案,因此:22
还需要端口说明符以使 Git 满意。如果没有端口,我在命令行上收到以下(奇怪的)错误消息:“ssh:连接到主机端口 22:连接被拒绝”。
By the way: When I added my repository in the Organizer window, Xcode mumbled something about "authentication is needed", then started to spin an activity indicator. Although I was able to clone the repo immediately, I had to restart Xcode to get rid of the activity indicator.
顺便说一句:当我在管理器窗口中添加我的存储库时,Xcode 嘟囔着“需要身份验证”,然后开始旋转活动指示器。虽然我能够立即克隆 repo,但我不得不重新启动 Xcode 以摆脱活动指示器。
回答by jesus
I found that using ssh://[email protected]/myrepo worked. Note that "git" is the username I used for gitolite (following the instructions on their website exactly, properly adding the public key for the users), git.mydomain.com is the hostname of where gitolite was installed, and "myrepo" is the name of the repository (it works without adding ".git" at the end for me).
我发现使用 ssh://[email protected]/myrepo 有效。请注意,“git”是我用于 gitolite 的用户名(完全按照他们网站上的说明,为用户正确添加公钥),git.mydomain.com 是安装 gitolite 的主机名,“myrepo”是存储库的名称(它无需在末尾添加“.git”即可工作)。
The other part is making sure that your OpenSSH keys are in ~/.ssh/id_rsa (private; chmod it to 0600 or it will not work) and ~/.ssh/id_rsa.pub (public; I don't know if this is needed but I never bothered to check).
另一部分是确保你的 OpenSSH 密钥在 ~/.ssh/id_rsa(私有;chmod 到 0600 否则它不会工作)和 ~/.ssh/id_rsa.pub(公共;我不知道这是否是需要的,但我从不费心去检查)。
The above works all the time, with no "side effects," at least for me...
以上一直有效,没有“副作用”,至少对我来说......
回答by clonepig
YOU should make sure you didn't enable any proxy , because it would cause the target unreachable in xcode sometimes.
您应该确保您没有启用任何代理,因为它有时会导致无法在 xcode 中访问目标。
Once you fill in the repository name, you must check if the repository "type" is git, not SVN, because I found xcode can change the type.
一旦你填写了仓库名称,你必须检查仓库“类型”是否是git,而不是SVN,因为我发现xcode可以改变类型。
Finally you should be successful to access the repo.
最后,您应该可以成功访问 repo。
回答by Chizuoka
I have my own GIT server using GIT-SCM.
我有自己的 GIT 服务器,使用 GIT-SCM。
I tried the URL ssh://[email protected]:22/gitname.git
and put the private keys in ~/.ssh/user
我尝试了 URLssh://[email protected]:22/gitname.git
并将私钥放入~/.ssh/user
CHMOD to 0600
CHMOD 至 0600
And when I connect it asks me for a username and password, but there is no password
当我连接时,它要求我输入用户名和密码,但没有密码
回答by Farlei Heinen
XCode 4 look for a key pair in the ~/.ssh directory
XCode 4 在 ~/.ssh 目录中查找密钥对
you need to add the public key to your user in the remote repository
您需要将公钥添加到远程存储库中的用户
then XCode can clone the repository
然后 XCode 可以克隆存储库
回答by Smoke Liberator
At least for Xcode 4.2, you don't need to specify a protocol. Just use
至少对于 Xcode 4.2,您不需要指定协议。只需使用
[email protected]:somerepo.git
Since I found this thread with a similar symptom but a different problem, I'll add that I had forgotten to add a key to gitosis for a new user so I was getting problems that I was thinking were Xcode related but were actually a gitosis configuration problem.
由于我发现该线程具有类似的症状但存在不同的问题,我将补充说我忘记为新用户添加 gitosis 的密钥,所以我遇到了一些我认为与 Xcode 相关但实际上是 gitosis 配置的问题问题。
回答by VonC
Cloning a Git repo through the git protocol(which is what you did in command line) isn't the same than using a ssh+git protocol(which is what you tried first in XCode4)
通过git 协议(这是您在命令行中所做的)克隆 Git 存储库与使用ssh+git 协议(这是您在 XCode4 中首先尝试的)不同
Only ssh would ask for a password, if no public key is found in your $HOME/.ssh
directory.
And if you have access to port 9418 on the server example.com
, you don't need ssh to clone (you might need it if there are an authentication layer set on the example.com
server though)
如果在您的$HOME/.ssh
目录中找不到公钥,则只有 ssh 会要求输入密码。
如果您可以访问服务器上的端口 9418,则example.com
不需要 ssh 进行克隆(如果example.com
服务器上设置了身份验证层,您可能需要它)
The "unable to connect a socke" error is typical of a firewall/proxy issue: see Git error: fatal: unable to connect a socket (Invalid argument).
“无法连接套接字”错误是典型的防火墙/代理问题:请参阅Git 错误:致命:无法连接套接字(无效参数)。
Check your git config -l
: it is possible XCode 4 don't use the exact same setting that your git used in command line.
检查您的git config -l
:XCode 4 可能不使用与您的 git 在命令行中使用的完全相同的设置。