首页 > 解决方案 > 如何将 core.sshCommand 选项传播到子模块更新?

问题描述

我已经core.sshCommand为 repo 设置了选项,以便在使用它时可以使用不同的 ssh 密钥(即sshCommand = ssh -i /path/to/key)。但是,当我运行git submodule update此选项时,不考虑:

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

有什么方法可以配置 repo 以将给定的 ssh 密钥用于自身和任何子模块?

标签: gitsshgit-submodulesssh-keys

解决方案


全局设置:

git config --global core.sshCommand "ssh -i /path/to/key"

但这为您使用的每个存储库设置了密钥。

或者为每个子模块设置它:

git submodule foreach git config core.sshCommand "ssh -i /path/to/key"

推荐阅读