Install older version of brew

Would like to reinstall this specific version of brew, to test:

brew -v
Homebrew 1.6.6
Homebrew/homebrew-core (git revision 28d4; last commit 2018-05-25)

Is it possible to do it to replicate the behaviour of that day?

I’m particularly nterested in being able to install any commit from scratch, from Sep 27 2017 to May 25 2018, both included.

Brew is just git underneath. You can just run cd $(brew --repo) and reset to an earlier tag. Just be aware that there’s no support for earlier versions of homebrew.

I’m not very familiar with repos, could you please help and provide which commands I have to run to download and install, say, revision 28d4?

cd $(brew --repo)/Library/Taps/homebrew/homebrew-core
git checkout 28d4210b0c

The repository will be reset to the particular commit/version. Proceed with any installations you wish. Keep in mind that some older formulae are not compatible with the current version of the brew command itself. Installations performed in this method are not supported if you run into issues.

When you’re ready to come back to the current commit/version:

cd $(brew --repo)/Library/Taps/homebrew/homebrew-core
git checkout master
brew update

Note that there are two parts to Homebrew:

  1. The brew command and support stuff, under the $(brew --repo) directory.
  2. The taps (software repos), which reside in their own directories. For example, the core tap mentioned in your brew -v output is in the $(brew --repo homebrew/core) directory.

For you to “replicate the behaviour of that day”, you have to revert both parts to the corresponding versions, else there may be a mismatch of functionality. Therefore:

# Revert Homebrew itself to v1.6.6
$ git -C $(brew --repo) checkout 1.6.6
# Revert the core tap to rev 28d4 @ 2018-05-25
$ git -C $(brew --repo homebrew/core) checkout 28d4210b0c

Alright, but how do I make it implicit with this command?:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Suppose I have a fresh install on macOS 10.13 and what to test if include folders are generated by the version of brew which was available at that time. Example error:
https://discourse.brew.sh/t/brew-gcc-does-not-install-properly

I don’t want to install current version of brew then downgrade, because may not replicate the issue. I want a direct install of the old version, scripts, formulaes and everything.

That’s not possible, everything in homebrew is made to always be on the latest version. The only way to exactly replicate the old setup is to manually clone all repositories that you need and to be very careful not to run any commands that would upgrade homebrew.

That’s not very helpful for debugging…