Skip to content

Instantly share code, notes, and snippets.

@cweekly
Forked from gcatlin/gist:1847248
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cweekly/10329382 to your computer and use it in GitHub Desktop.
Save cweekly/10329382 to your computer and use it in GitHub Desktop.
brew update
brew versions FORMULA
cd `brew --prefix`
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions"
brew install FORMULA
brew switch FORMULA VERSION
git checkout -- Library/Formula/FORMULA.rb # reset formula
## Example: Switch to git 1.9.0 in particular:
#
# $ brew versions git
## [ignore the warning about "brew-versions" being unsupported; it works well today]
# 1.9.1 git checkout 6801305 Library/Formula/git.rb
# 1.9.0 git checkout e2d162d Library/Formula/git.rb
# 1.8.5.5 git checkout 2fe5763 Library/Formula/git.rb
# 1.8.5.4 git checkout 5c6cb18 Library/Formula/git.rb
## ... etc ...
#
# $ cd `brew --prefix`
#
## copy/paste the 1.9.0 line above like so:
# $ git checkout e2d162d Library/Formula/git.rb
#
# $ brew install git
#
# $ brew switch git 1.9.0
#
# $ git checkout -- Library/Formula/git.rb
#
# $ git --version
# git version 1.9.0
#
## DONE :)
@mmottau
Copy link

mmottau commented Apr 10, 2014

After this step:
$ git checkout e2d162d Library/Formula/git.rb

I had to "brew unlink git" before installing.

I didn't have to:
$ brew switch git 1.9.0
$ git checkout -- Library/Formula/git.rb

@cweekly
Copy link
Author

cweekly commented Apr 10, 2014

Thanks Michael! Yeah, doing what brew says to do along the way is... the right thing to do.
Note if you have multiple versions of a formula installed, "brew link" may not work, hence "brew switch".
(Maybe you hadn't previously used brew to manage your git?) YMMV.
I'm not a homebrew expert, just sharing what worked for me. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment