如何使用带有ssh密钥的git子模块?

如何使用带有ssh密钥的git子模块?,git,github,Git,Github,我正在使用github的mainprivate存储库。 我在github上添加了deploy key in设置和Pull by命令: GIT_SSH_COMMAND="ssh -i /root/.ssh/repo.key" git pull 我还编辑了.git/config文件: [remote "origin"] url = git@github.com:username/reponame.git fetch = +refs/heads/*:refs/remotes/origin/*

我正在使用github的mainprivate存储库。 我在github上添加了deploy key in设置和Pull by命令:

GIT_SSH_COMMAND="ssh -i /root/.ssh/repo.key" git pull
我还编辑了.git/config文件:

[remote "origin"]
  url = git@github.com:username/reponame.git
  fetch = +refs/heads/*:refs/remotes/origin/*
它是有效的。 但我也有一个子模块(在私有repo中),我想通过ssh密钥像main repo一样来提取它。 我尝试向子模块repo和edit.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
我也试过:

cd misc/
GIT_SSH_COMMAND="ssh -i /root/.ssh/repo_sub.key" git pull
但它也不起作用


那么,如何通过密钥更新私有github repo中的子模块,或者如何通过密钥提取它们呢?

我在.git/modules中找到了子模块的配置,并将https链接更改为ssh

此命令正常工作后:

GIT_SSH_COMMAND="ssh -i /root/.ssh/repo_sub.key" git submodule update --remote misc/repo_sub