我如何使用 XCode 或 Sourcetree(在 Mac 上)通过 VPN 访问 GIT 存储库

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

How do i access a GIT repository through VPN with XCode or Sourcetree (on a mac)

xcodemacosgitatlassian-sourcetree

提问by NikkyD

It should be simple, but i just cant get anything to work.

它应该很简单,但我无法得到任何工作。

My Mac mini was connected to the office network (Windows server) and the repository is located on a server harddisk. I have a cloned working copy on the mac etc.

我的 Mac mini 已连接到办公网络(Windows 服务器),并且存储库位于服务器硬盘上。我在 mac 等上有一个克隆的工作副本。

Now the Mac is sitting somewhere else and is connected to the server via VPN. Because i dont know what exactly it does, let me describe what i was able to pull off. In finder with cmd+k i entered "smb://192.168.xxx.xxx" and the finder did show the server. I can access the data and the repository.

现在 Mac 位于其他地方并通过 VPN 连接到服务器。因为我不知道它到底做了什么,让我描述一下我能够实现的目标。在 finder 中使用 cmd+ki 输入“smb://192.168.xxx.xxx”,finder 确实显示了服务器。我可以访问数据和存储库。

I use sourcetree to access the git repository. In the bookmarks of sourcetree i can add it as a new repo and it says "This is a Git repository". Now when i hit "clone" it says "cloning from..." all fine... except, it never ends. Watched this for 10 minutes, no network traffic, no file appears on the harddrive. (waited longer... )

我使用 sourcetree 访问 git 存储库。在 sourcetree 的书签中,我可以将其添加为新的存储库,并显示“这是一个 Git 存储库”。现在,当我点击“克隆”时,它说“从……克隆”一切都很好……除了,它永远不会结束。看了 10 分钟,没有网络流量,硬盘上也没有文件。(等了很久……)

When i cancel this, the following line appears "Cloning into /Users/..." and "Completed with errors, see above" but there is no error above.

当我取消此操作时,以下行会出现“克隆到 /Users/...”和“已完成,但有错误,请参见上文”,但上面没有错误。

Now i opened the existing clone with sourcetree and attempted to change the repo location but i just dont know what to enter. It now starts with "/SomeFolder/..." and that folder still exists but now its behind the VPN. So what do i enter ? I tried some variations with IP etc but nothing worked and quite frankly im not getting along with my/a mac.

现在我用 sourcetree 打开了现有的克隆并尝试更改 repo 位置,但我只是不知道该输入什么。它现在以“/SomeFolder/...”开头,该文件夹仍然存在,但现在位于 VPN 后面。那么我输入什么?我尝试了 IP 等的一些变化,但没有任何效果,坦率地说,我对我的/一台 mac 不满意。

I really dont care about sourcetree, if its best to use plain XCode, so be it, but i need something that works.

我真的不关心 sourcetree,如果最好使用普通的 XCode,那就这样吧,但我需要一些有用的东西。

Update 1

更新 1

Im still having trouble. The answers with the SSH require a username, which one ? A former colleague set up this mac for me. I have a VPN Username, a win-domain user and an apple id... which of the 3 is meant in ur SSH lines ?

我还是有问题。SSH 的答案需要一个用户名,哪个?一位前同事为我设置了这台 mac。我有一个 VPN 用户名、一个 win 域用户和一个 Apple ID……这 3 个中的哪一个在您的 SSH 行中是指?

It may sound trivial but, when i enter the git rep folder, do i have to end the line with a slash or not ?

这可能听起来微不足道,但是,当我进入 git rep 文件夹时,是否必须以斜杠结束该行?

In the local network the rep folder just started with "/Data/..." so if i put an IP before that, does the IP need a slash before it as well ? I mean, on windows i would know what to do and the only reason why i ask these silly questions is because none of it seems to work on the mac :/

在本地网络中,rep 文件夹刚刚以“/Data/...”开头,所以如果我在此之前放置一个 IP,那么 IP 之前是否也需要一个斜杠?我的意思是,在 Windows 上我会知道该怎么做,我问这些愚蠢问题的唯一原因是因为它似乎在 mac 上不起作用:/

回答by DusteD

Use SSH,

使用 SSH,

you can do: git clone ssh://[email protected]/path/to/git_repository

你可以这样做: git clone ssh://[email protected]/path/to/git_repository

回答by Rob

I would recommend using Xcode, but using key pairs. And when you do that in Xcode, you have to do a little bit of extra configuration: just paste your keys into the ones it put into the repository it made for you then presto (this is how you use GitHub or BitBucket with Xcode).

我建议使用 Xcode,但使用密钥对。当你在 Xcode 中这样做时,你必须做一些额外的配置:只需将你的密钥粘贴到它为你制作的存储库中的密钥中,然后快速(这就是你在 Xcode 中使用 GitHub 或 BitBucket 的方式)。

The source control stuff in Xcode 5 is pretty awesome actually.

Xcode 5 中的源代码控制内容实际上非常棒。

http://www.elastichead.me/2013/01/github-and-xcode.html#.UpjarJGWyZY

http://www.elastichead.me/2013/01/github-and-xcode.html#.UpjarJGWyZY

回答by Jeremiah Smith

Two ways:
1) Open via Finder go to server, enter samba server data, leave that window open (it's the established connection to the server), then in XCode you can choose add repository inside the organizer (Cmd+Shift+2). or in XCode 5, it's under Preferences > Accounts, then plus button add repository

2) Another way would be to enable SSH access to the VPN Server, XCode supports SSH, just go into organizer, click "Add Repository", then enter in location field: ssh://[email protected]/path/to/git_repository It will ask your for the password.

两种方法:
1)通过Finder打开进入服务器,输入samba服务器数据,保持该窗口打开(这是与服务器建立的连接),然后在XCode中您可以选择在管理器内添加存储库(Cmd + Shift + 2)。或者在 XCode 5 中,它在 Preferences > Accounts 下,然后加号按钮添加存储库

2) 另一种方法是启用对 VPN Server 的 SSH 访问,XCode 支持 SSH,只需进入管理器,单击“添加存储库”,然后输入位置字段:ssh://[email protected]/path/to/git_repository 它会询问您的密码。