xcode-卸载删除xcode后无法使用git

1.官网安装的 git 位置在 /usr/local/git 目录

brew install git

2.xcode 默认会安装 git,位置在 /usr/bin 目录
卸载删除 xcode 后系统无法正确识别 git 位置,报错类似

xcrun: error: invalid active developer path (/Applications/Xcode.app/Contents/Developer), missing xcrun at: /Applications/Xcode.app/Contents/Developer/usr/bin/xcrun
'git log' failed with code 1:'xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
See `man xcode-select` for more details.'

3.使用以下命令安装 CommandLineTools,对 xcode 的配置进行重置

// 删除安装目录下的文件
sudo rm -rf /Library/Developer/CommandLineTools

// 安装 xcode-select
xcode-select --install
xcode-select --version

// 重置 CommandLineTools 配置
sudo xcode-select -r

// 配置 CommandLineTools PATH
sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

// 打印 CommandLineTools 配置
xcode-select -p
posted @ 2023-05-16 15:50  天生帅才  阅读(264)  评论(0编辑  收藏  举报
// 百度统计