[mac]Homebrewでgitをインストール(git-credential-osxkeychainのため)

MacPortsのgitを削除したら多分Mac標準のgitになったせいでgit-credential-osxkeychainが効かなくなったので、gitもHomebrewでインストールしました。

$ brew install git
~~~
Warning: Could not link git. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link git'

Possible conflicting files are:
/usr/local/etc/bash_completion.d/git-completion.bash

インストールするもsymlinkの作成に失敗したらしく実行できません。
Homebrewを入れた際に追加したgit-completion.bashが競合してるとのことなので、上記メッセージの通りYou can try again using `brew link git'を実行してみます。

$ brew link git

Linking /usr/local/Cellar/git/1.9.0... Warning: Could not link git. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/git/1.9.0/etc/bash_completion.d/git-completion.bash
Target /usr/local/etc/bash_completion.d/git-completion.bash already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
  brew link --overwrite formula_name

To list all files that would be deleted:
  brew link --overwrite --dry-run formula_name

また怒られました。
上書きするならbrew link --overwrite formula_nameとのことなので、

$ brew link --overwrite git
Linking /usr/local/Cellar/git/1.9.0... 208 symlinks created
[astha@astha-no-MacBook-Pro.local ~]$ which git
/usr/local/bin/git

うまくいきました。でもバージョンを確認すると・・・

$ git --version
git version 1.7.10.2 (Apple Git-33)

あれ?
whichでは/usr/local/bin/gitで1.9.0がインストールされているはずなのに、バージョンが古いままです。
変だなぁと思いつつwhichで新しいgitのパスになっていたのであまり深く考えず、Macを再起動したら新しいバージョンになりました。
git-credential-osxkeychainも使えています。

whichしたパスと、コマンドを実行した際のパスが異なるって不思議に思うのですが、もし理由がわかる方がいたら教えて下さいm_ _m

スポンサーリンク
336x280_1
336x280_1

シェアする

  • このエントリーをはてなブックマークに追加

フォローする

スポンサーリンク
336x280_1