Mac git指令无法执行相关问题

来源:互联网 发布:减肥淘宝排行榜 编辑:程序博客网 时间:2024/06/14 18:24

问题描述

在给Mac安装git时碰到一个问题,命令行无法执行git命令,提示

xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.

并弹出如下对话框提示安装Xcode
提示信息

原因分析

在Mac中,我安装了Xcode,安装Xcode时,会预装git wrapper,路径为:
/usr/bin/git
所以系统在执行git指令时先搜索到该路径,而本地安装的git路径为:
/usr/local/git/bin/git

解决方法

  1. 如果系统未安装Xcode,通过Xcode安装git
  2. 修改环境变量,将新的git路径写入系统环境变量
    打开.bash_profile文件,将新的git路径写进去,保存
    然后执行:$source ~/.bash_profile
PATH=/usr/local/git/bin:$PATHexport PATH

最后进行git测试,如果得到以下结果的话就ok了
测试图

参考

http://superuser.com/questions/666086/issues-installing-git-under-mac-os-x-10-9-mavericks

0 0
原创粉丝点击