Git is a distributed version control system that is widely used for tracking source code in software projects.
Install Git using Homebrew:
Easy steps to get git running on your macOS using Homebrew, a popular package manager for macOS.
- Open Terminal on your macOS.
- If you don’t have Homebrew, install using:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Once Homebrew is installed, you need to add /opt/homebrew/bin to your PATH. Run the following commands to add Homebrew to your PATH:
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/<user_name>/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"
- You can verify the version of Homebrew using:
brew --version
- Install git using:
brew install git
- Once git is installed, check the version using:
git --version
Install Git using MacPorts:
Another easy step is to get git running on your macOS using MacPorts, which is an open-source initiative.
- Open Terminal on your macOS.
- If you don’t have MacPorts, first install command line tools using:
xcode-select --install
If command line tools are already installed, you might have to add PATH to your bash profile using:touch ~/.bash_profile export PATH="/opt/local/bin:/opt/local/sbin:$PATH" source ~/.bash_profile
- Install git using:
sudo port install git
- Once git is installed, check the version using:
git --version