Installing Git on Multiple Operating Systems
The methods for installing Git on different operating systems are as follows:
macOS
-
Installing with Homebrew (Recommended):
- If you haven't installed Homebrew yet, you can run the following command in the terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- To install Git:
brew install git
- If you haven't installed Homebrew yet, you can run the following command in the terminal:
-
Using Xcode Command Line Tools:
- Open the terminal and run:
xcode-select --install
- This will install the Xcode Command Line Tools, which includes Git.
- Open the terminal and run:
-
Downloading from the Git Official Website:
- Visit the Git official website to download the macOS installer and follow the prompts to install it.
Linux
On Linux, the method of installing Git depends on the distribution you are using:
-
Debian/Ubuntu:
sudo apt update
sudo apt install git -
Fedora:
sudo dnf install git
-
CentOS/RHEL:
sudo yum install git
-
Arch Linux:
sudo pacman -S git
Windows
-
Using the Git for Windows Installer:
- Visit the Git for Windows official website to download the latest installer.
- Run the downloaded
.exe
file and follow the prompts of the installation wizard to install it.
-
Using the Windows Package Manager (winget):
- If you have already installed the Windows Package Manager, you can run the following in PowerShell:
winget install --id Git.Git -e --source winget
- If you have already installed the Windows Package Manager, you can run the following in PowerShell:
-
Using Chocolatey (if you have already installed Chocolatey):
- Run the following in the command prompt in administrator mode:
choco install git
- Run the following in the command prompt in administrator mode:
Verifying the Installation
Regardless of the operating system on which Git is installed, after the installation is complete, you can verify whether Git has been successfully installed by running the following command:
git --version
This will display the version number of the installed Git.