Brew Install Git
Git is released in versions. Which makes sense, but it’s not something I’ve thought about before. It became evident this week when I tried running a git command that my machine didn’t recognize.
git: 'switch' is not a git command. See 'git --help'.
I have always set up new developer laptops with
Xcode Command Line Tools, also both current ones. And that means I have the version of git that MacOS installs.
git --version git version 2.21.0 (Apple Git-122.2)
But whoa, this version is over a year old — and there have been multiple updates to the open source Git project since that. There are different ways to install git where you get the latest version, but I am going to use Homebrew 🍺 to manage it for me:
brew install git
At first I thought it didn’t work, but right… I need to open a new shell to try:
git --version git version 2.25.1
And yay, now I can use the newer alternative to
git checkout -b:
git switch -c my-new-branch Switched to a new branch 'my-new-branch'
Switch to a specified branch. The working tree and the index are updated to match the branch. All new commits will be added to the tip of this branch.
This command is going to be so much nicer to teach to new developers than “checkout”.