我正在使用来自 github 的主要私有存储库。我在 github 上的设置中添加了部署密钥并通过命令拉取:
GIT_SSH_COMMAND="ssh -i /root/.ssh/repo.key" git pull
Run Code Online (Sandbox Code Playgroud)
我也编辑 .git/config 文件:
[remote "origin"]
url = git@github.com:username/reponame.git
fetch = +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)
它有效。但是我也有一个子模块(在私有仓库中),我想通过像主仓库一样的 ssh 密钥来提取它。我尝试向子模块 repo 添加新密钥并编辑 .git/config:
[submodule "misc/repo_sub"]
url = git@github.com:username/repo_sub.git
GIT_SSH_COMMAND="ssh -i /root/.ssh/repo_sub.key" git submodule update --remote misc/repo_sub
Run Code Online (Sandbox Code Playgroud)
我也试过:
cd misc/
GIT_SSH_COMMAND="ssh -i /root/.ssh/repo_sub.key" git pull
Run Code Online (Sandbox Code Playgroud)
但它也不起作用。
那么如何通过密钥从私有 github repo 更新子模块,或者如何通过密钥拉出它们?
我在 .git/modules 配置中找到了子模块并将 https 链接更改为 ssh。
此命令工作正常后:
GIT_SSH_COMMAND="ssh -i /root/.ssh/repo_sub.key" git submodule update --remote misc/repo_sub
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4402 次 |
| 最近记录: |