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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16667686/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:24:57  来源:igfitidea点击:

Pushing over SSH to a GIT repository with Xcode 4.6

xcodegitssh

提问by Valentin Mercier

I am using Xcode 4.6 to develop my projects and I am using the local repository feature. However I would like to be able to push my repository to a remote ssh server.

我正在使用 Xcode 4.6 来开发我的项目,并且我正在使用本地存储库功能。但是,我希望能够将我的存储库推送到远程 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.

完成所有这些后,我返回到开发窗口并转到 File->Source Control->Push 但它说没有找到遥控器。

So I would like to know what should I do to make it work.

所以我想知道我应该怎么做才能让它发挥作用。

Thank you.

谢谢你。

采纳答案by trojanfoe

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:

然后将 repo 称为:

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 中运行良好,但是我在pull期间看到 repo 旁边的“绿灯” ,但在push期间看到 repo 旁边的“红灯” (这可能是 Xcode 5.1 beta 中的错误),但它可以正常工作并且不需要密码,如果您使用 Jenkins 进行发布构建,这非常好。

The Repositories under Preferences> Accountscannot connect using the ssh alias either, but strangely they function just fine when performing Source Control operations:

Preferences> Accounts下的 Repositories也无法使用 ssh 别名进行连接,但奇怪的是,它们在执行源代码控制操作时运行良好:

enter image description here

在此处输入图片说明

回答by Kozlov V

I resolve this problem with use ssh-agent, so :

我使用 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]

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]

回答by Segev

You address should look like this" ssh://[email protected]:2223/ios-app.gitYou don't need confirmation button. Also try not putting the password there. You'll be asked to enter it when you'll try to push.

你的地址应该像这样“ ssh://[email protected]:2223/ios-app.git你不需要确认按钮。也尽量不要把密码放在那里。当你尝试按下时,你会被要求输入密码。