Installing older versions of a Homebrew formula (2018 edition)

For debugging purposes, I recently needed to install an older version of Git on my Mac OS machine. I obviously didn't want to permanently replace the version of Git I was already using, I just wanted them to exist side-by-side and temporarily use the older version. Since Homebrew has the built-in ability to maintain multiple versions of a package simultaneously, it seemed like a good solution.

The problem is that the old way of grabbing historical formula versions (the "brew versions" command) was recently deprecated, and all of the advice I could find seemed to be equally outdated and conflicting.

Here's the method that worked for me:

  1. Find the version of the formula you want in the Homebrew repo. For instance, for Git, I looked at the history for the Git formula here:
  2. Click on the commit matching the version you want, and find the formula file for that version, i.e.
  3. Copy the "raw" link to that file, i.e.
  4. Now unlink your existing version of the formula locally: brew unlink git
  5. Finally, install the new version from the raw formula link above: brew install

After you are done testing, obviously be sure to switch back to the original package version, i.e. brew switch git 2.15.1_1. If you forget what version you had installed before, not to worry! It's still installed, you just have to find the version using brew list --versions. For good measure, manually verify that the new version is correct: git --version.