我最近买了一台 MacBook Pro。我注意到它预装了 git。这不是 git 的修补版本。因此,在遵循某些教程后,我使用以下步骤将 git 更新到最新的官方发行版
- 我安装了 Brew
我从brew运行了以下命令
brew install git
尽管当我从终端运行命令
git --version
时,我仍然指向以前的版本。我更新了路径变量以指向我的新官方发行版 git。
export PATH=/usr/local/bin:$PATH
此后,我看到我的版本已更新为正确的版本。我有以下疑问:
- 我是否丢失了 git 的官方 mac 版本?如果没有,mac版本的git安装在哪里?
- 我没有在 bash 配置文件中设置 git 环境变量,但当我关闭终端并重新打开它时,git 版本仍然正确显示。
- 如何更新 bash_profile 以开始从新安装的 git 版本读取内容?
最佳答案
Did I lose my offical mac version of git?
没有。
If not, where is the mac version of git installed?
/usr/bin/git.conf您可以使用 which -a git
在 PATH 中查找 git 的所有实例。
I did not set the git environment variable in my bash profile, still when I close the terminal and re-open it, git version is correctly shown. How can i update my bash_profile to start reading from my newly installed git version?
您仅为 shell 的当前实例设置了 PATH。您需要在 shell 配置中设置它。
您可以编辑 ~/.bash_profile
并添加您在 shell 中使用的同一行:export PATH=/usr/local/bin:$PATH
。但你不必这样做,/usr/local/bin 应该已经在你的 PATH 中,这就是brew 使用它的原因。您可能在/usr/local/bin 前面安装了另一个版本的 git(which -a git
会告诉您)。
尝试运行brew doctor
。请参阅brew troubleshooting guide了解详情。
关于git - 将 Git 更新到 MacBook Pro Sierra 上的官方发行版,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41919823/