This tutorial provides a detailed, step-by-step guide to installing Git on Windows, macOS, and Linux. By following these instructions, you will learn how to download, install, and verify Git on your operating system.
Install Git on Windows
To install Git on Windows, download the Git installer, run the setup wizard, and configure the installation options.
Step 1: Download Git
- Go to https://git-scm.com/downloads.
- Click on Windows to download the latest Git installer.
- Wait for the
.exe
file to download.
Step 2: Run the Installer
- Open the downloaded
.exe
file. - The setup wizard will appear. Click Next.
Step 3: Configure Installation Options
- Installation Path: Keep the default (
C:\Program Files\Git
) or choose a different location. - Select Components: Keep the default settings unless you need specific tools.
- Choose a Text Editor: Select your preferred editor (default is Vim, but you can choose VS Code, Notepad++, or another).
- Adjust PATH Environment: Choose Git from the command line and also from 3rd-party software (recommended).
Step 4: Complete the Installation
- Click Next until the installation begins.
- Click Install and wait for the process to finish.
- Click Finish and check Launch Git Bash if you want to open Git immediately.
Step 5: Verify Installation
Open Git Bash or Command Prompt and run:
git --version
If Git is installed correctly, it will display the version number.
Install Git on macOS
Git can be installed on macOS via Homebrew (recommended) or by downloading the installer.
Step 1: Check If Git Is Installed
macOS may already have Git installed. Open Terminal and run:
git --version
If Git is installed, the version number appears. If not, install Git using one of the methods below.
Step 2: Install Git Using Homebrew (Recommended)
Install Homebrew if you don't have it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Git:
brew install git
Verify the installation:
git --version
Alternative: Install Git Manually
- Download the Git installer from https://git-scm.com/download/mac.
- Open the
.dmg
file and follow the installation instructions. - Restart the terminal and check the installation:
git --version
Install Git on Linux
Git can be installed on Linux using the package manager specific to your distribution.
Step 1: Check If Git Is Installed
Run the following command:
git --version
If Git is installed, the version number will be displayed. Otherwise, install it using the commands below.
Step 2: Install Git Based on Your Distribution
Ubuntu/Debian:
sudo apt update
sudo apt install git -y
Fedora:
sudo dnf install git -y
CentOS:
sudo yum install git -y
Arch Linux:
sudo pacman -S git
Step 3: Verify Installation
After installation, check Git's version:
git --version
Configure Git After Installation
After installing Git, configure your user details:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
To confirm the configuration:
git config --list
This ensures that Git recognizes your commits correctly.
Conclusion
In this tutorial, you have learned how to install Git on Windows, macOS, and Linux. You have also verified the installation and configured Git with your user details. Now that Git is set up, you can start using it for version control and managing your code efficiently.