Mac - Xcode卸载后Git无法使用的解决
Xcode 卸载后 就出现了 如下情况 git命令失效了,如下报错:
1 2 3 | '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.' |
问题分析:肯定是xcode自带了git 导致删除了无法使用了,所以要修改原git路径或重新安装git
主要是重置之前的xcode的设置
注:没有安装的需要执行安装(往下看)
1 | xcode-select --install |
分三步命令 重置->修改路径指向->打印path路径 具体如下:
1 2 3 | sudo xcode-select -r sudo /usr/bin/xcode-select -- switch /Library/Developer/CommandLineTools xcode-select -p |
测试git命令:(能打印出版本号就是成功了)
1 2 | git --version git version 2.30.1 (Apple Git-130) |
PS:
第一句:就是让你重新指定希望用于命令行开发工具的Xcode,前提是你还有Xcode,重新安装Xcode
1 2 | Use `sudo xcode-select -- switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, // 使用' sudo Xcode -select -switch path/to/Xcode '。来指定您希望用于命令行开发工具的Xcode |
第二句:就是让你执行一条命令安装一个
1 2 | or use `xcode-select --install` to install the standalone command line developer tools. // 或者使用' Xcode -select -install '来安装独立的命令行开发工具 |
cmd执行一下
1 | xcode-select --install |
安装了一个独立的命令行开发工具,再次使用git操作,再无问题
Xcode命令行工具Command Line Tools(xcode-select)
一般Xcode安装后,第一次打开时,会弹窗提示安装Command Line Tools,直接安装即可。
如果当时没有安装,后面也可以单独安装。
1 2 3 | xcode-select --install // 安装命令 xcode-select --version // 查看版本 |
有时Command Line Tools出了问题,可以先尝试恢复默认设置来解决:
1 2 | // 恢复默认设置(需要sudo权限) sudo xcode-select --reset |
还是解决不了,可以考虑删掉后重新安装:
1 2 3 4 5 | // 强制删除安装目录下的文件 sudo rm -rf /Library/Developer/CommandLineTools // 重新安装 xcode-select --install |
除了终端命令的安装方式,也可以到苹果开发者官网的下载专区搜索Command Line Tools并下载安装包。
天行健,君子以自强不息;地势坤,君子以厚德载物!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决
2017-05-05 iOS - 使用苹果自带的UIVideoEditController进行视频编辑
2017-05-05 iOS - 使用MPMoviePlayerController播放在线视频
2017-05-05 iOS - 视频开发
2017-05-05 iOS - 仿微信朋友圈视频剪切功能
2017-05-05 iOS - 开源框架、项目和学习资料汇总(其他篇)
2017-05-05 iOS - 开源框架、项目和学习资料汇总(网络篇)
2017-05-05 iOS - 开源框架、项目和学习资料汇总(动画篇)