使用https访问git存储库,尽管它只提供ssh访问

时间:2017-11-30 11:54:46

标签: git gitlab

我们有一个ssh存储库,只能使用ssh访问。 我想将其导入Gitlab以便于查看。

不幸的是,gitlab只允许访问https。因此,我想设置一个小代理,提供由ssh连接备份的https接口。

是否已有一些现有的工具?否则有什么好主意吗?

关于近距离投票,我很确定没有这样的工具。因此问题是如何构建代理。 (关于git工具和配置的问题在这里很常见。)

1 个答案:

答案 0 :(得分:2)

您可以使用ssh克隆存储库,然后将其副本推送到Gitlab(使用ssh或https)。

# Make a clone over ssh of your existing project
git clone git@somehost.com:myuser/myproject.git

# Add another remote that points to gitlab, and push to it
git remote add gitlab git@gitlab.com:myuser/myproject.git
git push -u gitlab master

将项目导入Gitlab后,您可以(如果需要)进入项目设置并使用ssh设置镜像。 (使用ssh进行镜像是正常的;它仅适用于Gitlab要求http / https的初始导入。)此设置位于项目设置的“存储库”部分中,例如在

https://gitlab.com/{your_username}/{project_name}/settings/repository