LoginSignup
4
0

More than 3 years have passed since last update.

Homebrewでgitのバージョンを管理する(Mac)

Last updated at Posted at 2019-12-22

概要

gitをインストールしようと思ったら、すでにX-codeをインストールした時に一緒に入っていたみたい。Homebrewでgitをインストールして、すでに入っていたgitを上書きする。

現在の状況

  • gitのバージョン
terminal
$ git version
git version 2.20.1 (Apple Git-117)

Apple Git-117と書いてあるのが、どうやら勝手にインストールされたということらしい。

Homebrewでgitをインストール

以下のコマンドを入力してgitをインストールする。

terminal
$ brew update
$ brew install git

gitのバージョンを確認してみる。

terminal
$ git version
git version 2.20.1 (Apple Git-117)

変わってない。どうもパスが通っていないようなのでパスを通してあげる。

パスを通す

~/.bash_profileに今回インストールしたgitのパスを優先的に見に行くように設定を書き込む。

terminal
$ echo 'export PATH=/user/local/git/bin:$PATH' >> ~/.bash_profile

更新した~/.bash_profileを実行して、バージョンを確認する。

terminal
$ source ~/.bash_profile
$ git version
git version 2.23.0

ちゃんとパスが通っていることを確認して、終わり。

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0