从Git版本2.3.0可以使用环境变量GIT_SSH_COMMAND,如下所示:
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_example" git clone example
请注意,-i有时可以被您的配置文件覆盖,在这种情况下,您应该给SSH一个空配置文件,如下所示:
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_example -F /dev/null" git clone example
GIT_SSH_COMMAND='ssh -i ~/.ssh/id_rsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' git clone user@host