2017-08-14 187 views
0

我正在使用主要私人存储库从github。 我加入GitHub上设置部署的关键,并通过命令拉:如何将git子模块与ssh密钥一起使用?

GIT_SSH_COMMAND="ssh -i /root/.ssh/repo.key" git pull 

而且我编辑的.git/config文件:

[remote "origin"] 
    url = [email protected]:username/reponame.git 
    fetch = +refs/heads/*:refs/remotes/origin/* 

和它的作品。 但我也有一个子模块(在私人回购),我想通过ssh键像主回购拉。 我尝试新的键添加到子模块回购和编辑的.git /配置:

[submodule "misc/repo_sub"] 
    url = [email protected]: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回购密钥更新子模块或如何可以通过密钥拉他们?

回答

0

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

该命令后工作正常:

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