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 @   天生帅才  阅读(346)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具
// 百度统计
点击右上角即可分享
微信分享提示