Published on

Reinstalling Git with Homebrew to Get the Latest Version

Last Modified on
Last modified on
Authors
Reinstalling Git with Homebrew to Get the Latest Version
Photo by Brett Sayles on Pexels

Note: You have to already have Homebrew installed in order to install Git with Homebrew.

Yesterday I updated Xcode on macOS Monterey, and found out that it did not include the latest version of Git. So I decided to re-install it with Homebrew, if I could.

I could, and I did, but it involved a bit of a hack. Since macOS El Capitan, we are not able to make changes to the bin folder due to SIP (System Integration Protection) on our Macs. We have to disable it and then re-enable it after making the changes we need to make. I did not want to have to go through the process of doing this if I could avoid it, and it would have meant more time in doing so. Instead, before I re-installed Git with Homebrew, I created an alias:

alias git='/usr/local/bin/git'

I ran the above command in Terminal. Then I "re-installed" Git with Homebrew. I came across the steps to do so in a Github Gist, and the alias workaround as well. To read through this Gist, please visit Re-installing Git on Mac OSX with Brew on Github. I found the alias suggestion from within the comments.

The alias worked for me and was much quicker to implement, so I stuck with it. I ran the following commands to install Git with Homebrew:

brew uninstall git
brew update
brew install git

The first command did nothing for me, because I did not previously install Git with Homebrew. I ran the second command to update Homebrew (always recommended before installing something with Homebrew). And the third command actually installed Git with Homebrew.

Happy distributed version control with Git!