Starting from Git 2.3.0 we also have the simple command (no config file needed):
1
GIT_SSH_COMMAND='ssh -i private_key_file -o IdentitiesOnly=yes' git clone user@host:repo.git
With git 2.10+ (Q3 2016: released Sept. 2d, 2016), you have the possibility to set a config for GIT_SSH_COMMAND
A new configuration variable core.sshCommand
has been added to specify what value for GIT_SSH_COMMAND
to use per repository.
1
2
3
4
cd /path/to/my/repo/already/cloned
git config core.sshCommand 'ssh -i private_key_file -o IdentitiesOnly=yes'
# later on
git pull