This forces a full reinstall of all homebrew packages, fixing the dyld: Library not loaded errors when trying to run git, psql, node etc. This often happens after using Apple's Migration Assistant. Also can be caused by macOS updates.
brew list -1 > brew.txt # list out all installed packages
brew list -1 | xargs brew rm --force # remove all installed packages
brew install $(cat brew.txt | tr '\n' ' ') # install all previously installed packages