git - 如何将 Gitlab 自我管理的子模块连接到 deepsource.io
问题描述
我想将一个 git 子模块连接到 deepsource.io。它说我需要通过 SSH 连接它。主存储库托管在 Github 上,子模块由 Git 实验室自管理(git.server.com)托管。
我必须在哪里粘贴 deepsource.io 的公共 SSH 密钥?我必须在我的帐户或子模块上连接它还是如何连接?
解决方案
在 deepsource.io 上生成 SSH 密钥后(通过导航到存储库的设置 > SSH 访问 > 生成 SSH 密钥对),复制提供的公钥并将其作为部署密钥添加到 GitLab 子模块存储库(设置 > 存储库 > 部署键)。不要授予对密钥的写权限。
如果您使用 HTTPS URL 来指定子模块(查看.gitmodules
存储库根目录中的文件),则需要将它们更改为 SSH URL。为此,您可以
- 直接编辑
.gitmodules
文件:如果文件看起来像这样:
[submodule "screamer"]
path = screamer
url = https://git.myserver.com/org/screamer.git
你可以改变它看起来像
[submodule "screamer"]
path = screamer
url = git@git.myserver.com:org/screamer.git
- 运行如下命令:
git config --local url.git@git.myserver.com:.insteadOf https://git.myserver.com/
这将更改您的.git/config
文件,如下所示:
[url "git@git.myserver.com:"]
insteadOf = https://git.myserver.com/
推荐阅读
- laravel - laravel 重定向回发布路线,我得到 MethodNotAllowedHttpException
- json - React Native 显示简单的 Json 数据
- java - 位图与 R.drawable
- matlab - MATLAB - 将文件夹内容作为字符串数组获取
- spring - 带有 Angular 登录端点的 Spring Security?
- java - 自定义适配器中的意图
- ruby-on-rails - 在 Rails 集成测试中存根 `session_id`
- android - 使用提供的 upload_cert.der 签署发布的 Android APK 文件
- typescript - TypeScript 承诺
- javascript - 读取加载我的页面时返回的脚本的属性