Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 如何将core.sshCommand选项传播到子模块更新?_Git_Ssh_Git Submodules_Ssh Keys - Fatal编程技术网

Git 如何将core.sshCommand选项传播到子模块更新?

Git 如何将core.sshCommand选项传播到子模块更新?,git,ssh,git-submodules,ssh-keys,Git,Ssh,Git Submodules,Ssh Keys,我为repo设置了core.sshCommand选项,以便在使用它时可以使用不同的ssh密钥(即sshCommand=ssh-I/path/to/key)。但是,当我运行git子模块更新时,不考虑此选项: fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 是否有任何方法可以配置repo为其自身和

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

fatal: Could not read from remote repository.

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

是否有任何方法可以配置repo为其自身和任何子模块使用给定的ssh密钥?

或者全局设置它:

git config --global core.sshCommand "ssh -i /path/to/key"
但这为您使用的每个存储库设置了关键

或者为每个子模块设置:

git submodule foreach git config core.sshCommand "ssh -i /path/to/key"
根据这个,我从这里引述这句话

Git2.10.0中添加了
core.sshCommand
选项。您运行的是2.7.4,它没有该功能。如果你想使用它,你需要升级到一个更新的Git

如果您运行的是非常旧的版本,请注意这些更改。你可以参考这个

您可以改用环境变量GIT\u SSH\u命令

export GIT_SSH_COMMAND="/usr/bin/ssh -i /your/path/to/id_rsa"

不为我工作。无法添加子模块,因为它选择了错误的ssh密钥。
git submodule foreach
在现有子模块中运行。对于刚刚添加的新子模块,您需要一些类似于git-c core.sshCommand=“ssh-i/path/to/key”的子模块添加
您能够解决这个问题吗?@ArkaPravaBasu提供了我的帮助吗?您好@JohnStrood,我随后解决了这个问题。@ArkaPravaBasu是的,您也可以这样做,但如果您想在本地设置它,这对您没有帮助,例如,如果您想将不同的repo克隆到不同的github帐户。@ArkaPravaBasu,尽管您可以要求ssh连续尝试所有密钥。当您拉/推时,设置env
GIT\u SSH\u命令将更加优雅。