Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with Git when installing Homebrew: "Error: Git is unavailable"

Tags:

git

homebrew

This is what I get when I try to install Homebrew: Error: Git is unavailable

Downloading and installing Homebrew...
Error: Git is unavailable

It gives me an error and says that Git is unavailable, although I have downloaded Git and installed it.

like image 650
S. Caperna Avatar asked Jul 21 '26 22:07

S. Caperna


1 Answers

Make sure that you have your brew updated. First run the following command:

brew doctor

Now, if you get Your system is ready to brew, you can move on to install Git.

With Homebrew, installing Git is as easy as this:

brew update
brew install git

Note: it's a good habit to run update before installing anything with Homebrew because Homebrew is updated regularly.

To verify:

git --version

You should get git version 2.3.1 or later.

Run brew doctor to make sure everything is still working. In case brew doctor doesn't work you can use these commands:

cd `brew --prefix`
git remote add origin https://github.com/Homebrew/homebrew.git
git fetch origin
git reset --hard origin/master
brew update

Already up-to-date.

If you're seeing permission errors tried running

sudo chown -R $(whoami) $(brew --prefix)

Or if it complains that any directories inside /usr/local aren't writable, fix it with this command:

sudo chown -R `whoami` /usr/local

Lastly, if you get Warning: /usr/bin occurs before /usr/local/bin, run the command below and quit and relaunch Terminal:

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

This command takes everything between the single quotes and adds it >> to a file called .bash_profile in your user's root directory ~/. Every time you open a new Terminal window or tab, .bash_profile is called. The export PATH line tells your system to look in /usr/local/bin first, since that's where Homebrew installs tools.

Download and Install the Command Line Tools

For El Capitan, Yosemite and Mavericks
  1. Inside the Terminal window, copy and paste (or type) the following command, and press the return key on your keyboard:

    xcode-select --install
    
  2. You should see the pop up below on your screen. Click Install when it appears.

install xcode

  1. Click Agree when the License Agreement appears.

  2. Your computer will then attempt to find the software, and then will start downloading it. The following popup will appear:

  3. Once the software is installed, click Done. That's it! You're now ready to go to Step 2.

install xcode, done

like image 79
Teocci Avatar answered Jul 23 '26 13:07

Teocci