Use another SSH key/command for Git
If you need to use a different SSH key for a git command such as git push
you can do so by setting the GIT_SSH_COMMAND
environment variable like so:
GIT_SSH_COMMAND="ssh -i ~/.ssh/custom_key" git push
This can become a lot easier to use if you define that env var automatically when entering a directory by using direnv.
h/t Thomas Allen
Tweet