简体   繁体   English

使用Xcode 4.6将SSH推送到GIT存储库

[英]Pushing over SSH to a GIT repository with Xcode 4.6

I am using Xcode 4.6 to develop my projects and I am using the local repository feature. 我正在使用Xcode 4.6开发我的项目,我正在使用本地存储库功能。 However I would like to be able to push my repository to a remote ssh server. 但是,我希望能够将我的存储库推送到远程ssh服务器。

I have tried the following but it did not work : I went to the organizer and then to my repository, I have then added a new remote with the following instructions : - Name : Just a name so I have put my project name - Location : I have put a ssh path : user@domain:path_to_my_.git_folder 我尝试了以下但是它没有用:我去了组织者然后到我的存储库,然后我添加了一个新的遥控器,其中包含以下说明: - 名称:只是一个名字所以我已经把我的项目名称 - 位置:我已经放了一个ssh路径:user @ domain:path_to_my_.git_folder

Then I have entered my ssh password, but there was no confirmation button though. 然后我输入了我的ssh密码,但是没有确认按钮。

Once all this was done I returned to the development window and went to File->Source Control->Push but it says there is no remote found. 完成所有这些后,我返回到开发窗口并转到文件 - >源代码控制 - >推送,但它说没有找到远程。

So I would like to know what should I do to make it work. 所以我想知道我该怎么做才能让它发挥作用。

Thank you. 谢谢。

I have found the best solution for repo's on github and bitbucket is to create an SSH key-pair with no password. 我在github和bitbucket上找到了repo的最佳解决方案是创建一个没有密码的SSH密钥对。

$ cd .ssh
$ ssh-keygen -t rsa -b 2048 -f github_id_rsa
$ vi config

Then add the following: 然后添加以下内容:

Host github
    HostName github.com
    User git
    IdentityFile ~/.ssh/github_id_rsa

And to then refer to the repo as: 然后将回购称为:

ssh://github/trojanfoe/myrepo
      ^^^^^^
(note that's the name of the "Host" from the config file, not github.com)

This works well in Xcode, however I see "green lights" next to the repo during a pull , but "red lights" next to the repo during a push (this might be a bug in Xcode 5.1 beta), but it works without complaint and without the need for a password, which is great if you use Jenkins to do your release builds. 这在Xcode中运行良好,但是在拉动期间我看到回购旁边的“绿灯”,但是在推送期间回购旁边的“红灯”(这可能是Xcode 5.1 beta中的错误),但是它没有投诉并且不需要密码,如果您使用Jenkins进行发布构建,这是很好的。

The Repositories under Preferences > Accounts cannot connect using the ssh alias either, but strangely they function just fine when performing Source Control operations: 首选项” >“ 帐户”下的存储库也无法使用ssh别名进行连接,但奇怪的是,它们在执行源代码管理操作时功能正常:

在此输入图像描述

你的地址应该是这样的“ ssh://git@git.urlOrLocal.com:2223/ios-app.git你不需要确认按钮。也不要把密码放在那里。你会被要求输入它当你试图推动。

我使用ssh-agent解决了这个问题,所以:

eval `ssh-agent -c` [start the ssh-agent]
ssh-add ~/.ssh/id_dsa [enter your passphrase when you are prompted for it]
ssh-add -l [lists out what keys are loaded in the agent]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM