简体   繁体   English

Gitlab - Xcode 无法与远程存储库连接

[英]Gitlab - Xcode Can't connect with remote repository

I am having troubles when I connect with my repository through Xcode.当我通过 Xcode 连接到我的存储库时遇到了麻烦。

I have a Gitlab version (full pre-)installed on TurnkeyLinux Virtual Appliance on a remote server.我在远程服务器上的 TurnkeyLinux 虚拟设备上安装了 Gitlab 版本(完全预装)。 In the Gitlab Web interface, I've created a new test user: "testuser" with a password "password" and a new project "testproject".在 Gitlab Web 界面中,我创建了一个新的测试用户:“testuser”,密码为“password”和一个新项目“testproject”。 This user was assigned to this project.此用户已分配给此项目。

The git url project are: git url 项目是:

HTTP: http://example.com/testuser/testproject.git
SSH: git@example.com:testuser/testproject.git

I can see the repositories folder rightly created with a "Terminal" through SSH connection.我可以看到通过 SSH 连接使用“终端”正确创建的存储库文件夹。

Now, I want add this git repository to my Xcode repositories.现在,我想将此 git 存储库添加到我的 Xcode 存储库中。

So, In所以,在

XCode > Preferences > Account     

I'm trying add it, using both urls and my user credentials, but always receive the following message:我正在尝试使用 url 和我的用户凭据添加它,但总是收到以下消息:

"Authentication failed because the name or password was incorrect."

Could anyone help me?有人可以帮助我吗?

The user/password would only be needed for an http url, not an ssh one.用户/密码只需要 http url,而不是 ssh 一个。

When using the http url to add a repo in your XCode Accounts , make sure there is no proxy which would prevent the resolution of the example.com server.使用 http url 在 XCode 帐户中添加存储库时,请确保没有代理会阻止example.com服务器的解析。

If it is still not working, then, as in " Authentification issue when pushing Xcode project to GitHub ", try to use an url like:如果它仍然不起作用,那么,如“将 Xcode 项目推送到 GitHub 时的身份验证问题”,请尝试使用如下网址:

https://testuser:password@example.com/testuser/testproject.git

Even if the problems seems solved I've found this question when I had the problem using XCode 10. I tried logging in to GitHub and got the same error.即使问题似乎已经解决,我在使用 XCode 10 遇到问题时也发现了这个问题。我尝试登录 GitHub 并遇到相同的错误。 The workaround described didn't fix my problem but I've found another solution on my own which I'd like to share – maybe it helps somebody ;)所描述的解决方法并没有解决我的问题,但我自己找到了另一个我想分享的解决方案——也许它对某人有帮助;)

My GitHub password included an 'ä' character (I'm German) and seems XCode and GitHub don't support the used encoding.我的 GitHub 密码包含一个“ä”字符(我是德语),似乎 XCode 和 GitHub 不支持使用的编码。 After changing my password to something without an 'ä' it worked fine.将我的密码更改为没有 'ä' 的密码后,它工作正常。 Maybe it wasn't because of the 'ä' but it already helped to change the password - I don't know.也许不是因为 'ä' 但它已经有助于更改密码- 我不知道。

Thank you, but the reasons are Xcode seems a little crazy…谢谢,但原因是 Xcode 似乎有点疯狂……

In

Xcode > Source Control > Test Project (master) > Configure Test Project…

I've just added my repository HTTP URL and credentials were not needed, and when I trying push/pull actions Xcode ask me for user/password.我刚刚添加了我的存储库 HTTP URL 并且不需要凭据,当我尝试推/拉操作时,Xcode 会询问我的用户/密码。

Seems to be Repository in Preferences > Account doesn't work fine…似乎是 Preferences > Account 中的 Repository 不能正常工作......

you'd better use the project configuration:你最好使用项目配置:
'Source Control' > '(project name)-Master' > 'Configure (project name)', 'Source Control' > '(project name)-Master' > 'Configure (project name)',
select 'Remote', choose '+' > Add Remote选择“远程”,选择“+”> 添加远程
Name : origin名称 : 产地
Address : git@gitlab.com:xxx/yyy.git地址:git@gitlab.com:xxx/yyy.git
(Curiously it appears after this in the XCode prefs) (奇怪的是它出现在 XCode 首选项之后)

Don't forget: using SSH, the password is the one you used (keygen) when building the key !不要忘记:使用 SSH,密码是您在构建密钥时使用的密码 (keygen)!

I don't want to use HTTP!我不想使用 HTTP! Key file under "git" user is very convenient and secure, I'm not going to type my password in a unencrypted URL entry in some plist file. “git”用户下的密钥文件非常方便和安全,我不会在某些 plist 文件的未加密 URL 条目中键入我的密码。

In my case, the problem was that Xcode was trying to use the wrong key file :就我而言,问题是 Xcode 试图使用错误的密钥文件:

.ssh/id_rsa
instead of 而不是
.ssh/id_dsa .ssh/id_dsa

Here using Xcode 7.3.1 and finally managed to push using ssh (and Gogs as github server) by doing so:这里使用 Xcode 7.3.1 并最终设法使用 ssh(和 Gogs 作为 github 服务器)进行推送:

1) select the correct private key (there must also be the public key file present) 1) 选择正确的私钥(还必须存在公钥文件)

on Gogs side:在 Gogs 方面:

2) add that same key from the Gogs user Settings->SSH Keys 2) 从 Gogs 用户设置->SSH 密钥添加相同的密钥

3) under admin panel: Dashboard: Operations: rewrite the authorised_keys file 3)在管理面板下:仪表板:操作:重写authorised_keys文件

Done完成

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

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