How to Install Git Command Line: Windows, macOS, and Linux
By Arshath | August 12, 2026
Install Git on your Windows, macOS, or Linux system by following the correct installation method for your operating system. Git is available for all major operating systems, including Windows, macOS, and Linux. Most macOS and Linux distributions already include Git or make it available through their default package manager.
Before installing Git, check whether it is already available on your system. Once installed, verify the installation to ensure Git is ready to use.

Prerequisites: Check if Git Is Already Installed
Before you install Git, check whether Git is already installed on your Windows, macOS, or Linux system. Running the git –version command displays the installed Git version or indicates whether Git needs to be installed.
1. On macOS
- Open the Terminal app.
2. On Windows
- Open Command Prompt or Git Bash.
3. On Linux
- Open the Terminal app by pressing Ctrl + Alt + T.
Run the following command:
git --version
The output will either display the installed Git version or indicate that Git is not installed. If Git is not installed, follow the installation steps for your operating system.
Steps and Commands to Install Git on Different OS:
Install Git on Windows by downloading the latest Git for Windows installer from the official website. Follow the setup wizard to install Git and verify the installation using the git –version command.
1. Install Git on Windows:
Step 1: Download the latest Git for Windows installer from Git Windows Installer.
Step 2: Once you start the installer, the Git Setup wizard will appear. Click Next and Finish to complete the installation. The default settings are suitable for most users.
Step 3: Open Command Prompt or Git Bash.
Step 4: Verify the installation by running:
git --version
Important Note:
Git for Windows is the most popular and recommended way to install Git on Windows. Downloading Git from git-scm.com ensures you get the latest stable version of Git along with Git Bash, a command-line interface that provides a Unix-like terminal experience for running Git commands on Windows.
You can install Git Bash on Windows using the command line with the built-in Windows Package Manager (winget).
2. Install Git on macOS:
There are three ways to install Git on macOS. While most installation methods are maintained by trusted third parties, they may not always include the latest Git release immediately. Choose the installation method that best suits your needs.
Option 1: Using Homebrew (Recommended)
Homebrew is the recommended package manager for installing Git on macOS. Install Git with a single command and keep it updated easily through Homebrew.
If MacPorts is not installed, install it and run the below command.
brew install git
Option 2: Using MacPorts
If you use MacPorts to manage software packages, you can install Git after updating your package definitions. This method integrates Git into your existing MacPorts environment.
Ensure your package definitions are completely up-to-date:
sudo port selfupdateIf MacPorts is not installed, install it and run the below command.
sudo port install git
Option 3: Using Xcode Command Line Tools
Xcode Command Line Tools include Git and other essential developer tools for macOS. Installing these tools is a simple way to get Git without installing a separate package manager.
- Run the following command:
xcode-select --install
- A dialog box will appear. Follow the on-screen prompts to confirm and finish the installation
- Verify the Installation:
After the installation is complete, run:
git --version
If the command returns the installed Git version, the installation was successful.
3. Install Git on Linux:
The easiest way to install git on Linux is by using your distribution’s package manager. Select your Linux distribution and run the appropriate command in the Terminal.
Debian / Ubuntu
- Update packages: Update your local package index.
sudo apt update
To install git on ubuntu, follow the below process.
- Install: Download and set up the Git package.
sudo apt install git
Install the Latest Stable Version (Ubuntu Only)
Once the installer starts, you’ll see the Git Setup wizard. Click Next and then Finish to complete the installation using the default options.
- Add the PPA Repository:
sudo add-apt-repository ppa:git-core/ppa
- Update:
sudo apt update
- Install:
sudo apt install git
Fedora (dnf/yum)
Install Git on Fedora using the DNF package manager or YUM on older Fedora releases. Both package managers install Git from the official Fedora repositories.
Git packages are available via both yum and dnf:
Install Git using dnf (or yum, on older versions of Fedora):
sudo dnf install git
(or)
sudo yum install git
Red Hat Enterprise, CentOS, Rocky, Alma, and Oracle:
Install Git on RHEL-based distributions using DNF on modern releases or YUM on older versions. The package manager automatically installs Git and its required dependencies.
For RHEL 8/9 and other modern RHEL-based distributions:
sudo dnf install git
For older RHEL/CentOS versions:
sudo yum install git
Arch Linux
Install Git on Arch Linux using the Pacman package manager. Pacman downloads and installs the latest Git package available in the official Arch repositories.
sudo pacman -S git
openSUSE
Install Git on openSUSE using the Zypper package manager. This command downloads Git from the official openSUSE repositories.
sudo zypper install git
Gentoo
Install Git on Gentoo using the Portage package manager with the emerge command. Portage resolves and installs all required dependencies automatically.
sudo emerge --ask dev-vcs/git
Alpine Linux
Install Git on Alpine Linux using the APK package manager. This lightweight installation method is suitable for Alpine-based systems and containers.
apk add git
Mageia
Use the URPMI package manager to install Git on Mageia. The package manager retrieves Git from the official Mageia repositories.
sudo urpmi git
Nix / NixOS
Install Git on NixOS using the Nix package manager. This command adds Git to your user profile without affecting the rest of the operating system.
nix profile install nixpkgs#git
FreeBSD
Install Git on FreeBSD using the PKG package manager. The package manager downloads and installs the latest available Git package.
sudo pkg install git
OpenBSD
Install Git on OpenBSD using the pkg_add command with doas. This method installs Git from the official OpenBSD package repositories.
doas pkg_add git
Solaris (OpenCSW)
Install Git on Solaris using the appropriate package manager for your Solaris distribution. OpenCSW and Solaris 11 Express/OpenIndiana provide official Git packages for installation.
pkgutil -i git
Solaris 11 Express / OpenIndiana
pkg install developer/versioning/git
SliTaz
Install Git on SliTaz using the tazpkg package manager. The package manager downloads and installs Git from the SliTaz repositories.
tazpkg get-install git
Verify the Installation
After successful installation of above process, verify the installation using the below command to show the latest version.
git --version
If the command displays the installed Git version, the installation was successful.
Other Git Useful Resources:
1. 8 Simple Steps to Connect Github to cPanel
2. Top 8 Common Git Commands Used by Developers
You have successfully installed Git on your Windows, macOS, or Linux system. With Git installed, you can start tracking changes to your projects, collaborate with others, and manage your code efficiently.
