Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

brew update failure while executing git checkout

Tags:

homebrew

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
$
like image 930
Julien Carsique Avatar asked Feb 21 '12 00:02

Julien Carsique


3 Answers

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.
like image 116
Julien Carsique Avatar answered Nov 14 '22 08:11

Julien Carsique


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
like image 3
yuzebin Avatar answered Nov 14 '22 07:11

yuzebin


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.

like image 2
Nick Woodhams Avatar answered Nov 14 '22 08:11

Nick Woodhams