Migrate Brew from Intel to M1 mac

How to get brew running after switch to M1 mac

This guide assumes you have migrated to at new M1 based mac via timemachine, mac-to-mac or similar.

Running brew update then gives the following messeage:

Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
You can migrate your previously installed formula list with:
  brew bundle dump

Running brew bundle dump as suggested creates a file in your current folder named Brewfile

Migration process

1. Install brew

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

2. Import from Brewfile

Run the following command from the same folder as you ran brew bundle dump

brew bundle --file Brewfile

This transfers all previous installed app.