This script adds awareness to Git about which SSH key should be used when pushing to remotes over SSH.
- Run the
setup-alias.sh
- Open the config of repository you want to set the key path of:
repoName/.git/config
- Add the following to it, replacing
$HOME/.ssh/key-name
with your key path
[SSH]
keypath = $HOME/.ssh/key-name
You can now push and pull as normal but Git will use the key you have specified
All that happens is the alias looks for the config variable SSH.keypath
and if found exports the value of the config
entry to an environment variable named GIT_SSH_COMMAND
. Git uses this when it does anything SSH related and will make
use of the key you configured.
Git v2.3 or above