LoginSignup
7
1

More than 1 year has passed since last update.

【Git】インストーラー版のGitをアンインストールする方法とは?(Mac標準のGitに戻す)

Posted at

はじめに

GitインストーラーのGitをアンインストールして、Mac標準のGitに戻す方法を書いてみます。
何かの参考になればと思います。

前提

  • macOSを使用予定(macOS Monterey バージョン12.4)
% sw_vers
ProductName:	macOS
ProductVersion:	12.4
BuildVersion:	21F79
%
  • シェルはzshを使用
% which zsh
/bin/zsh
%
  • 作業前のGitの状況
% where git
/usr/local/bin/git
/usr/bin/git
  • それぞれのGitのバージョン
Mac標準版
% /usr/bin/git --version
git version 2.32.1 (Apple Git-133)
% 
インストーラー版
% /usr/local/bin/git --version
git version 2.27.0
% 

アンインストール手順

  • uninstall.shの存在を確認

/usr/local/git/と若干場所が違うようです。

コマンド
ls /usr/local/git/ | grep uninstall.sh
実行例
% ls /usr/local/git/ | grep uninstall.sh
uninstall.sh
% 
  • uninstall.shの実行

ディレクトリを移動した後に、インストーラー版Gitのアンインストールを実施する。

コマンド
・ディレクトリの移動
cd /usr/local/git/

・アンインストールの実施
sh ./uninstall.sh
実行例
% cd /usr/local/git/
% sh ./uninstall.sh
This will uninstall git by removing /usr/local/git/, and symlinks
Type 'yes' if you are sure you wish to continue: yes
Password:
Forgot package 'com.git.pkg' on '/'.
Uninstalled
%

※削除するかどうか聞かれるが、yesで進める。

  • 削除後の確認

whereコマンドを実行し、/usr/bin/gitのみであることを確認

コマンド
where git
実行例
% where git
/usr/bin/git
%

whichコマンドも実行し、/usr/bin/gitが出力されることを併せて確認。

実行例
% which git
/usr/bin/git
%
  • バージョン確認

以下コマンドを実行し、Mac標準のGitのバージョンが表示されることを確認する。

コマンド
git --version
実行例
% git --version
git version 2.32.1 (Apple Git-133)
%

さいごに

人によって前提の環境が違うことがあると思いますので、あくまでも一例としてご参考頂けますと幸いです。

参考記事

7
1
1

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