LoginSignup
0
1

More than 3 years have passed since last update.

macOSでhomebrewを使ってGitのバージョンを最新化する方法

Posted at

前提条件

OSバージョン: macOS Mojave Version 10.14.6
homebrewがインストール済みであること

手順

1. リリースされているGitの最新バージョンを確認

Git公式サイト
https://git-scm.com/
Screen Shot 2020-07-05 at 21.23.56.png

2. 自分のmacOSに入っているGitのバージョンを確認

$ git --version
git version 2.xx.x 

ここで入れたはずのパッケージのバージョンになっていない場合、パスが通っていない可能性あり。

3. homebrewでインストールされたGitパッケージの場所を探す

$ brew --prefix git
/usr/local/opt/git

このディレクトリを見ると、コマンドのバイナリ自体は以下にあることがわかるので
/usr/local/opt/git/bin --- ※

4. homeディレクトリにある.bash_profileに以下を追加

gitのパスを通します。
viで開いて※をパスに追加し上書き保存。

export PATH=/usr/local/opt/git/bin:$PATH

ターミナルを再起動して、バージョンを再確認。

$ git --version
git version 2.27.0 

おわり。

0
1
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
0
1