Add a file called .bashrc to your home folder. Open the file and paste in:
#!/bin/bash
eval `ssh-agent -s`
ssh-add
# Stop ssh-agent if session is closed.
trap 'test -n "$SSH_AGENT_PID" && eval `/usr/bin/ssh-agent -k`' 0
This assumes that your key is in the conventional ~/.ssh/id_rsa location. If it isn't, include a full path after the ssh-add command. Add to or create file ~/.ssh/config with the contents
ForwardAgent yes
Restart Msysgit. It will ask you to enter your passphrase once, and that's it (until you end the session, or your ssh-agent is killed.)
The bash terminal used by the latest Git for Windows 2.5.0 (mintty) doesn't bother to read .bashrc - it reads .bash_profile. So you can set up your environment in .bash_profile and/or put this code at the start to read .bashrc:
if [ -f ~/.bashrc ]
then
. ~/.bashrc
fi
#Mac/OS X
Add your key to the Mac OS Keychain:
ssh-add -K ~/.ssh/id_rsa
Source:
http://stackoverflow.com/a/10077302/456814
http://stackoverflow.com/a/32189255
https://www.safaribooksonline.com/library/view/linux-security-cookbook/0596003919/ch06s11.html