开发者

Using a gitosis git repository with XCode 4

开发者 https://www.devze.com 2023-02-25 11:41 出处:网络
Hi I\'ve been trying to access my git repository from XCode 4. Everything works just fine using the command line tools. I can clone my repo using:

Hi I've been trying to access my git repository from XCode 4.

Everything works just fine using the command line tools. I can clone my repo using:

git clone git@example.开发者_JAVA百科com:somerepo.git

But in XCode, when trying to use:

ssh://git@example.com: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://git@example.com:somerepo.git

Except that i also get a "Connection refused: unable to connect to a socket" error message.

Any idea how to solve this?


In Xcode 4.2, the following location string worked for me

ssh://git@example.com: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. Without the port, I got the following (weird) error message on the command line: "ssh: connect to host port 22: Connection refused".

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.


I found that using ssh://git@git.mydomain.com/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).

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).

The above works all the time, with no "side effects," at least for me...


XCode 4 look for a key pair in the ~/.ssh directory

you need to add the public key to your user in the remote repository

then XCode can clone the repository


At least for Xcode 4.2, you don't need to specify a protocol. Just use

git@example.com: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.


YOU should make sure you didn't enable any proxy , because it would cause the target unreachable in xcode sometimes.

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.

Finally you should be successful to access the repo.


I have my own GIT server using GIT-SCM.

I tried the URL ssh://user@git.mydomain.com:22/gitname.git and put the private keys in ~/.ssh/user

CHMOD to 0600

And when I connect it asks me for a username and password, but there is no password


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)

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)

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).

Check your git config -l: it is possible XCode 4 don't use the exact same setting that your git used in command line.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号