While brew has an accessible simple versioning mechanism, it's restricted to versions used by a large number of people. So for popular versions, it's easy:
brew search node # gives node@6, node@8, node@10
brew search postgresql #gives postgresql@9.4, postgresql@9.5, postgresql@9.6, postgresql@10
brew search python # gives python@2
And I can install one for instance with brew install python@2
.
But for less popular versions which got removed, let's say git@2.20.1
, then it's not obvious how to install them:
$
brew install git@2.20.1
Error: No available formula with the name "git@2.20.1"
==> Searching for a previously deleted formula (in the last month)…
Error: No previously deleted formula found.
==> Searching for similarly named formulae…
Error: No similarly named formulae found.
==> Searching taps…
==> Searching taps on GitHub…
Error: No formulae found in taps.
Best Answer
Solution based on Versions.html doc
To install a removed brew formula version, we can follow the suggestion from https://docs.brew.sh/Versions.html:
git commit --allow-empty -m "first commit"
), otherwise brew may not find HEAD.brew extract git Coeur/repo --version=2.20.1
brew install coeur/repo/git@2.20.1
(note: uninstall command will be
brew uninstall git@2.20.1
)More doc at https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap
Solution based on manual search
brew info git
. It should tell us it's https://github.com/Homebrew/homebrew-core/blob/master/Formula/git.rbbrew install https://raw.githubusercontent.com/Homebrew/homebrew-core/67903b677219559ac72b3fb45932d43426e157f0/Formula/git.rb
(note: uninstall command will be
brew uninstall git
)