【问题标题】:WARNING: Your version of git is 1.9.3. has serious security vulnerabilities警告:您的 git 版本是 1.9.3。存在严重的安全漏洞
【发布时间】:2015-02-23 02:48:06
【问题描述】:

我在部署到 Heroku 期间收到有关 git 1.9.3 严重安全漏洞的警告

我尝试通过 homebrew 更新 git,但发现 git 最初不是通过 homebrew 安装的

然后我通过自制软件安装了它

brew update
brew install git

==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/git-2.2.1.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring git-2.2.1.mavericks.bottle.tar.gz
==> Caveats
The OS X keychain credential helper has been installed to:
/usr/local/bin/git-credential-osxkeychain

The "contrib" directory has been installed to:
/usr/local/share/git-core/contrib

Bash completion has been installed to:
/usr/local/etc/bash_completion.d

zsh completion has been installed to:
/usr/local/share/zsh/site-functions
==> Summary
????  /usr/local/Cellar/git/2.2.1: 1356 files, 31M

之后,当我检查 git 版本时,它保持不变

⇒  git --version   
git version 1.9.3 (Apple Git-50)    

在我看来 homebrew 在文件夹 /usr/local/Cellar/git/2.2.1

中安装了 git

最后是我的问题: 我应该怎么做才能开始使用 homebrew git 而不是原来的 git

【问题讨论】:

    标签: macos git security heroku homebrew


    【解决方案1】:

    就像 Jubobs 评论的那样,您可以像这样简单地将其添加到您的路径中:

    echo 'export PATH="/usr/local/git/bin:$PATH"' >> ~/.bash_profile

    只需将 ~/.bash_profile 更改为您正在使用的任何 bash 配置文件。

    【讨论】:

    • 谢谢@mrstif,但它不能解决在我的IDE(RubyMine)中更新git的新路径的问题
    • 当然@SergeSeletskyy,对于 git 文件夹的硬编码引用,您可以直接使用您的解决方案更改它,或者只需编辑软件的设置...
    • 这对我有用,但你能解释一下为什么这解决了我的问题吗?
    • @katzkode 这基本上是因为系统的 PATH 变量定义了哪些可执行文件可以直接在您的终端中找到。我提供的命令只是将新的 Git 安装文件夹添加到该变量的前面,因此当您在终端中键入“git”时,系统将从第一个开始的 PATH 变量中指定的文件夹中查找该命令。由于新安装是第一个,它将选择那个而不是系统的。更多信息PATH
    【解决方案2】:
    ⇒  which git
    /usr/bin/git
    
    ⇒  git --version
    git version 1.9.3 (Apple Git-50)
    

    你需要在/usr/bin/git重命名原来的git,例如

    sudo mv /usr/bin/git /usr/bin/git-original
    

    现在再次检查位置和版本

    ⇒  which git
    /usr/local/bin/git
    
    ⇒  git --version
    git version 2.2.1
    

    添加符号链接以实现向后兼容性(以防您的 IDE 使用 git 的直接位置)

    sudo ln -s /usr/local/bin/git /usr/bin/git
    

    【讨论】:

    • 感谢@Jubobs,但无论如何我都需要在我的IDE中更改git的路径
    • mv: 将 /usr/bin/git 重命名为 /usr/bin/git-original: 不允许操作
    猜你喜欢
    • 1970-01-01
    • 2016-10-19
    • 1970-01-01
    • 2011-11-07
    • 2018-09-02
    • 1970-01-01
    • 1970-01-01
    • 2020-11-25
    • 2022-12-19
    相关资源
    最近更新 更多