我刚买了一台新的Mac,安装了OS X Lion系统,我在终端上检查了默认安装的git版本。我知道答案了
git --version
> git version 1.7.5.4
我想把git升级到最新的1.7.8.3版本,所以我下载了dmg安装程序“git-1.7.8.3-intel-universal-snow-leopard”。dmg”,然后我启动了它。
安装完成后,终端仍然显示版本为1.7.5.4。我做错了什么?
我刚买了一台新的Mac,安装了OS X Lion系统,我在终端上检查了默认安装的git版本。我知道答案了
git --version
> git version 1.7.5.4
我想把git升级到最新的1.7.8.3版本,所以我下载了dmg安装程序“git-1.7.8.3-intel-universal-snow-leopard”。dmg”,然后我启动了它。
安装完成后,终端仍然显示版本为1.7.5.4。我做错了什么?
当前回答
在谷歌上搜索“在mac上升级git遇到麻烦”后,我阅读了几篇文章,并尝试了以下步骤,然后通过完成步骤4解决了问题:
I updated my terminal path by using the above mention export command. Every time I quit the terminal and restarted it, when I typed git --version the terminal, it still return the older version 1.8. I followed the README.txt instructions for upgrading to the current version 2.0.1 that comes with the .dmg installer and when I restarted the terminal, still no go. I looked for /etc/path/ folder as instructed above and the directory called "path" does not exist on my Mac. I am running OS X Mavericks version 10.9.4. Then I recalled I have Homebrew installed on my Mac and ran the following: brew --version brew update brew search git brew install git
这终于解决了我的问题。如果有人有一些见解,为什么这工作,进一步的见解将大大赞赏。我的系统上可能还有一些去年使用Ruby时遗留下来的路径设置。
其他回答
@rafaecheve的回答在我这个Mac用户身上非常有效。我在我的机器上安装了几个版本的git,但是使用了包管理器,Homebrew和以下代码:
brew link --overwrite git
我收到这个确认
Linking /usr/local/Cellar/git/2.32.0... 212 symlinks created.
拖鞋!
我最近也把我的OS X机器上的Git升级到了最新版本。我没有使用您使用的.dmg,但当我安装它时,二进制文件被放置在/usr/local/bin中。现在,根据我的PATH的排列方式,目录/usr/bin出现在/usr/local/bin之前。所以我所做的是:
cd /usr/bin
mkdir git.ORIG
mv git* git.ORIG/
这将把几个名为git*的原始程序移动到一个新的子目录中,使它们不受影响。在此之后,哪个git显示找到了/usr/local/bin中的文件。
根据需要修改上面的过程,以适应您安装新二进制文件的地方。
如果你能补充以下内容可能会更好:
export PATH=/usr/local/git/bin:/usr/local/sbin:$PATH
到主文件夹中名为.bashrc的文件。这样,您可能安装在/usr/local/git/bin中的任何其他软件也将首先被找到。
一个简单的方法就是输入:
echo "export PATH=/usr/local/git/bin:/usr/local/sbin:$PATH" >> ~/.bashrc
到终点站,它会为您办理的。
如果你已经有了Homebrew,这很简单: 假设你已经安装了自制程序,输入以下内容:
brew install git
这将自动安装git,并将其设置在您的路径中,取代Apple的路径。
现在退出并重新启动您的终端。
然后查看git版本确认。
git --version
如果上面命令的输出显示了最新的版本,并且没有提到Apple的版本细节,那么您就已经设置好了。
如果你仍然看到苹果版本,那么输入下面两行,这将手动将我们的路径设置为本地git发行版而不是苹果发行版。
export PATH=/usr/local/bin:$PATH
git --version
如果你没有自制的,按照下面的步骤来做
检查版本
巨债
备份(或删除)Apple git(可选)
$ sudo mv /usr/bin/git /usr/bin/git-apple
如果你没有Homebrew,请安装
ruby美元/ usr / bin / e,“美元(卷毛-fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
如果已经更新了,也可以更新
$ brew update && brew升级
用Homebrew安装Git
安装git
符号链接
$ brew链接—强制git
退出终端,打开新终端,检查版本。
巨债
你应该看到……
Git版本<最新版本>
好了!我们现在安全了!下次你可以…
$ brew update && brew升级
在谷歌上搜索“在mac上升级git遇到麻烦”后,我阅读了几篇文章,并尝试了以下步骤,然后通过完成步骤4解决了问题:
I updated my terminal path by using the above mention export command. Every time I quit the terminal and restarted it, when I typed git --version the terminal, it still return the older version 1.8. I followed the README.txt instructions for upgrading to the current version 2.0.1 that comes with the .dmg installer and when I restarted the terminal, still no go. I looked for /etc/path/ folder as instructed above and the directory called "path" does not exist on my Mac. I am running OS X Mavericks version 10.9.4. Then I recalled I have Homebrew installed on my Mac and ran the following: brew --version brew update brew search git brew install git
这终于解决了我的问题。如果有人有一些见解,为什么这工作,进一步的见解将大大赞赏。我的系统上可能还有一些去年使用Ruby时遗留下来的路径设置。