39

After an interrupted brew update because of a network issue, Homebrew appears to be broken:

$ brew update
error: pathspec 'master' did not match any file(s) known to git.
Error: Failure while executing: git checkout -q master 

Looking at the /usr/local Git repository, there's no remote repository.

$ cd `brew --prefix`
$ git remote -v
$
0

5 Answers 5

101

Fixed with the following 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.
5
  • 3
    I got 403s from github with the https URL for the repo. This worked for me: $ git remote add origin git://github.com/mxcl/homebrew.git
    – jongala
    Jun 13, 2012 at 21:36
  • 2
    brew update never works first time. There's always issues with the working tree.
    – Rob
    Oct 3, 2012 at 9:37
  • I'm currently getting the following, possibly from a Github DDOS: /usr/local at owne-pc (master ✔)% brew update error: Failed connect to github.com:443; Operation timed out while accessing https://github.com/mxcl/homebrew.git/info/refs fatal: HTTP request failed Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master Aug 15, 2013 at 16:21
  • for whatever reason, some of my files were owned by root. Must have used sudo at some point. I chown'd the files to my regular user and followed these instructions and it worked great.
    – Tim G
    Dec 9, 2014 at 0:49
  • I had to run git clean -f after running git reset --hard origin/master. Apr 2, 2015 at 22:38
3

when i try it, sudo is needed:

$ git reset --hard origin/master
error: unable to unlink old 'Library/Homebrew/macos/xcode.rb' (Permission denied)
fatal: Could not reset index file to revision 'origin/master'.
$ sudo !!
sudo git reset --hard origin/master
Password:
HEAD is now at 97302bf xrootd 3.2.2
1
2

In my case, I had just upgraded to OS X El Capitan and none of the other solutions worked.

I took note of the packages in /usr/local/Cellar and then deleted the Cellar folder and started with a fresh install.

rm -rf /usr/local/Cellar
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )"

Then I brew installed the packages again.

1

I had a similar problem where from /usr/local (== $(brew --prefix)) I tried the answer by @ Julien Carsique but still got the error:

[local]master$ git checkout 3115d85 hdf5.rb
error: pathspec '3115d85' did not match any file(s) known to git.
error: pathspec 'hdf5.rb' did not match any file(s) known to git.

This was because I the hdf5 routine was in /usr/local/Library/tab/homebrew-science which has it's own git repository. To fix this I entered:

[local]master$ cd Library/Taps/homebrew/homebrew-science/
[homebrew-science]master$ git checkout 3115d85 hdf5.rb

Now I can install a previous version of the desired library (e.g. hdf5)

Hope this helps someone!

0

What solved Homebrew git errors for me was simply to cd ~ and run brew update in my home directory. The command failed when I was in a folder shared on GitHub. Also, clang magically appeared again from brew config after cd ~.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.