我如何在Mac OS X 10.9上安装和使用最新的Git? [英] How can I install and use latest Git on Mac OS X 10.9?

查看:183
本文介绍了我如何在Mac OS X 10.9上安装和使用最新的Git?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 http://git-scm.com/download/mac从sourceforge下载了Git 2.4.3 为我的Macbook Pro OS X 10.9.5,然后安装它。



当我在终端输入 git --version 时,出现以下消息:

  xcode-select:note:在'/Applications/Xcode.app'找不到开发人员工具,请求安装。 
在对话框中选择一个选项来下载命令行开发工具

当我输入 which git 出现: / usr / bin / git



<当我输入 git版本2.4.3 时出现: git version 1.9.5(Apple Git-50.3)



然后我安装了Xcode。当我输入上述命令到终端时,出现了相同的结果。



然后卸载Git。



如何安装和使用最新版本的Git?

解决方案

要安装Git而不使用Xcode,可以使用 Homebrew (这对于安装其他工具也很棒) - 强烈推荐。我比较喜欢使用Homebrew来执行专门的下载和安装选项,比如用于Git。



设置Homebrew后,您可以使用它来安装和更新许多其他命令

安装Homebrew可以这样完成:

  ruby​​ -e$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)

在终端中执行此操作,它会为您的用户安装Homebrew。 Homebrew Wiki 有更多安装选项。

一旦你安装了Homebrew,你可以用它来安装最新版本的Git:

  brew install git 

只要确保你更新了你的 PATH 变量包含 / usr / local / bin ,因为这是Homebrew将安装Git可执行文件的地方。您似乎正面临着终端仍然在路径上使用不同Git可执行文件的问题。要更新PATH变量,请在文本编辑器中编辑文件〜/ .bash_profile ,并确保它包含如下内容:

  export PATH = / usr / local / bin:$ PATH 

保存此文件后,关闭当前的终端窗口并打开一个新窗口 - 它应该使用新的PATH设置。



在此之后,键入

 哪个git 

查找当前终端会话使用的Git可执行文件的位置。


I downloaded Git 2.4.3 from sourceforge via http://git-scm.com/download/mac for my Macbook Pro OS X 10.9.5, then installed it.

When I typed git --version into the terminal, this message appeared:

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

When I typed which git this appeared: /usr/bin/git.

When I typed git version 2.4.3 this appeared: git version 1.9.5 (Apple Git-50.3).

I then installed Xcode. When I typed the above commands into the terminal, the same results appeared.

I then uninstalled Git.

How can I install and use the most recent version of Git?

解决方案

To install Git without using Xcode, you can use Homebrew (which is great for installing other tools as well) - it comes highly recommended. I prefer using Homebrew over the dedicated download and install options like you used for Git.

Once you have set up Homebrew, you can use it to install and update many other command line tools with a single command.

Installing Homebrew can be done like this:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Execute this in a Terminal, it will install Homebrew for your user. The Homebrew Wiki has more installation options.

Once you have installed Homebrew, you can use it to install the latest version of Git:

brew install git

Just make sure that you update your PATH variable to include /usr/local/bin, since this is where Homebrew will install the Git executable. You seem to be facing the problem that your Terminal is still using a different Git executable on the path. To update your PATH variable, edit the file ~/.bash_profile in a text editor and make sure that it includes something like this:

export PATH=/usr/local/bin:$PATH

After saving this file, close your current Terminal window and open a new one - it should then use the new PATH setting.

After this, type

which git

to find the location of the Git executable that's used by your current Terminal session.

这篇关于我如何在Mac OS X 10.9上安装和使用最新的Git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆