V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
leohxj
V2EX  ›  问与答

Mac 下 xCode 中的 git 如何升级?

  •  
  •   leohxj · 2014-08-23 00:05:33 +08:00 · 7888 次点击
    这是一个创建于 3548 天前的主题,其中的信息可能已经有所发展或是发生改变。
    先安装了xcode,命令行下git --version,显示的是:git version 1.8.5.2 (Apple Git-48)

    通过brew install git,安装的是2.1版本, brew安装的路径是: /usr/local/Cellar/git/2.1.0。

    我想知道如何让命令下的git也是2.1版本,且以后通过brew update时也能自动更新。
    第 1 条附言  ·  2014-08-23 00:38:23 +08:00
    我刚又看了下brew,发现有一个命令: brew doctor。他会提示我设置PATH:
    echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

    这样brew下载的git就能在系统自带的之前了。。。

    是我不熟悉mac, 低级问题,抱歉。
    11 条回复    2014-11-21 22:39:01 +08:00
    dullwit
        1
    dullwit  
       2014-08-23 00:19:16 +08:00 via Android   ❤️ 1
    $ sudu mv /usr/bin/git /usr/bin/git-apple
    #brew升级
    $ brew update
    $ brew outdated #查看更新内容
    $ brew upgrade
    $ brew cleanup
    bianzhifu
        2
    bianzhifu  
       2014-08-23 00:20:18 +08:00   ❤️ 1
    mv /usr/bin/git git.bak
    ln -s /usr/local/Cellar/git/2.1.0/git /usr/bin/git
    bianzhifu
        3
    bianzhifu  
       2014-08-23 00:20:55 +08:00
    mv /usr/bin/git /usr/bin/git.bak
    ln -s /usr/local/Cellar/git/2.1.0/git /usr/bin/git
    bianzhifu
        4
    bianzhifu  
       2014-08-23 00:21:59 +08:00
    我错了 没明白你的意思 我这么搞以后升级会有问题 试试1楼的做法吧
    dullwit
        5
    dullwit  
       2014-08-23 00:25:18 +08:00 via Android
    @bianzhifu brew安装是全局的
    leohxj
        6
    leohxj  
    OP
       2014-08-23 00:38:09 +08:00   ❤️ 1
    @dullwit
    @bianzhifu
    我刚又看了下brew,发现有一个命令: brew doctor。他会提示我设置PATH:
    echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

    这样brew下载的git就能在系统自带的之前了。。。

    是我不熟悉mac, 低级问题,抱歉。
    ffffwh
        7
    ffffwh  
       2014-08-23 00:40:25 +08:00   ❤️ 1
    改PATH环境变量,把/usr/local/bin放到前面去。不过GUI程序的PATH环境变量得研究研究。

    似乎苹果有套奇怪的机制,/usr/bin/xxx不是实际的executable。在更新xcode、java等后会自动指向实际的executable。
    chlx
        8
    chlx  
       2014-08-23 01:42:27 +08:00 via Android
    /etc/paths
    jedihy
        9
    jedihy  
       2014-08-23 12:19:07 +08:00 via iPhone
    我觉得不要升级,感觉下次升级xcode的时候可能会出问题
    turandot
        10
    turandot  
       2014-11-21 14:34:25 +08:00
    @leohxj echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile执行后,还是老样子,检查.bash_profile已经是/usr/local/bin在前了,莫名。。。
    leohxj
        11
    leohxj  
    OP
       2014-11-21 22:39:01 +08:00
    @turandot 你用zsh的话,应该加到.zshrc中
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   973 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:23 · PVG 04:23 · LAX 13:23 · JFK 16:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.