githubにssh接続する設定をしているが、毎回手動でssh-agentを起動するのがめんどくさい。
git bashの起動時にssh-agentが自動で起動するように設定する。
手順
・git bashのホームディレクトリに「.bashrc」と「.bash_logout」を作成する
$ touch .bashrc $ touch .bash_logout
・git bashを起動すると以下の警告が出る
WARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or ~/.profile. This looks like an incorrect setup. A ~/.bash_profile that loads ~/.bashrc will be created for you.
訳:「.bash_profile」が見つからないので作っておいたよ
$ ls -a .bash* .bash_history .bash_profile .bashrc
・「.bashrc」に以下の内容を記載する
eval "$(ssh-agent)" ssh-add ~/.ssh/rsa_github
・「.bash_logout」に以下の内容を記載する
eval `ssh-agent -k`
EOF