参考:http://effectif.com/mac-os-x/installing-specific-version-of-homebrew-formula
carthageを例に書いています。
specify_version.sh
# formulaのディレクトリへ移動
$ cd /usr/local/Library/Formula/
# 一回怒られる
$ brew log carthage
Warning: The git repository is a shallow clone therefore the filtering may be incorrect.
Use `git fetch --unshallow` to get the full repository.
$ git fetch --unshallow
remote: Counting objects: 324024, done.
remote: Compressing objects: 100% (79532/79532), done.
remote: Total 324024 (delta 247862), reused 319162 (delta 243007), pack-reused 0
Receiving objects: 100% (324024/324024), 61.09 MiB | 207.00 KiB/s, done.
Resolving deltas: 100% (247862/247862), completed with 3307 local objects.
From https://github.com/Homebrew/homebrew
470ea39..0e00db6 master -> origin/master
# もう一回。欲しいバージョンのハッシュ値をコピー
$ brew log carthage
$ git checkout c6fa6777 carthage.rb
$ brew unlink carthage
$ brew install carthage
元の状態に戻す
fix_version.sh
$ cd /usr/local/Library/Formula/
$ git checkout master carthage.rb