$ brew update
$ brew upgrade
I’ve blindly typed the above commands for too long without understanding what they actually do. This article is to explain in simple words what these commands do.
When you first install brew for the first time by following instructions here, you actually download a git repository of homebrew-core into your machine at `/usr/local/Homebrew`
That repository holds all the ruby scripts, called Formulae which hold the logic to install each package that you can install using brew command.
So when you do brew install <package_name>, it tries to find the formulae under the above repository and runs it.
brew update and upgrade
brew update updates the above downloaded git repository with the latest code from GitHub.
brew upgrade updates the actual packages to match the versions in the updated local git repository.
Let me know if this not helpful in the comments and I will update the article as suggested.
Take Care, Cheers.