How can I install and use latest Git on Mac OS X 1

2019-07-09 05:44发布

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?

2条回答
你好瞎i
2楼-- · 2019-07-09 06:05

You may need the command line tools for XCode. After you install XCode, run sudo xcode-select --install to install them. Then try installing git again.

查看更多
倾城 Initia
3楼-- · 2019-07-09 06:07

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.

查看更多
登录 后发表回答