ponkiti's blog

主に自分用、イベント参加メモや備忘録として利用

HomebrewでインストールしたGitを優先的に使うよう設定する

環境

$ brew -v
Homebrew 0.9.5

事象

Homebrewで最新版のGit(今回は2.2.1)をインストールしたが、Mac標準のGitが指定されていて、HomebrewのGitが使用できない。

$ brew install git
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/git-2.2.1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring git-2.2.1.yosemite.bottle.tar.gz
(省略)
==> Summary
🍺  /usr/local/Cellar/git/2.2.1: 1356 files, 31M

$ git --version
git version 1.9.3 (Apple Git-50)

手順

パスを通すため、.bash_profileファイルにexport PATH=/usr/local/bin:$PATHを追記する。

$ vi ~/.bash_profile

$ cat ~/.bash_profile
export PATH=/usr/local/bin:$PATH

変更内容を反映させるため、sourceコマンドを実行する。

$ source ~/.bash_profile

バージョンを確認すると、HomebrewでインストールしたGitが反映された。

$ git --version
git version 2.2.1