如何卸载Git的安装器版本并恢复为Mac标准的Git?
首先
我将写下一种方法来卸载Git安装程序中的Git,并恢复到Mac标准的Git。希望对您有所帮助。
前提 tí) – prerequisite, prerequisite condition, assumption
- 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のバージョン
% /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
%
※在被问到是否要删除时,选择“是”以继续进行。
- 削除後の確認
执行”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)
%
最后
因为我认为每个人的前提环境都可能不同,所以请将以下内容仅作为一个例子供您参考,我将不胜感激。
依据以上文章