How to install and configure Git on Windows, Mac, and Linux?

First published: Tuesday, October 10, 2023 | Last updated: Tuesday, October 10, 2023

Know how to download, install, and configure Git on your Windows, Mac, and Linux operating systems for seamless Git operations.


What is Git?

Git is a distributed VCS for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows.

Install Git

The process of installing Git varies depending on the operating system - Windows, Mac, or Linux. It’s crucial to keep in mind that Git is mainly a command-line tool regardless of the installation method. Once the installation is finished, it’s essential to verify the installed Git version to confirm that it was successful. Additional comprehensive instructions and further details can be found in the official Git documentation.

Windows

  1. Download the Git installer.
  2. Execute the Git installer, and proceed with Next and Finish prompts to install Git.

After installing Git on your Windows operating system, you’ll want to verify the installation by using the following commands.

# Check Git version.
$ git --version

Mac (MacPorts)

You can use the following commands to install Git in the MacPorts-based Mac operating system.

# Install Git.
$ sudo port install git

# Check Git version.
$ git --version

Mac (Homebrew)

You can use the following commands to install Git in the Homebrew-based Mac operating system.

# Install Git.
$ brew install git

# Check Git version.
$ git --version

Linux (RPM)

You can use the following commands to install Git in RPM-based Linux operating systems such as CentOS LinuxRed Hat LinuxFedora LinuxAmazon LinuxAlma LinuxRocky Linux, etc., or any other similar equivalents.

# Install Git.
$ sudo yum install git

# Check Git version.
$ git --version

Linux (Debian)

You can use the following commands to install Git in Debian-based Linux operating systems such as Ubuntu LinuxMint LinuxKali LinuxKubuntu Linux, etc., or any other similar equivalents.

# Install Git.
$ sudo apt install git

# Check Git version.
$ git --version

Configure Git

When you configure Git with the –global option, it will be used for all Git repositories of the current system user. This configuration is important because each commit you make will include this information, which helps in tracking who made changes to the source code. If you want to use a different username or email address for a specific repository, navigate to that Git repository and use the same commands without the –global option.

Windows

Please open the Git Bash terminal in administrator mode and run the below commands to configure the Git username and email address on the Windows operating system.

# Configure global username in Git.
$ git config --global user.name "USERNAME"

# Configure global email address in Git.
$ git config --global user.email "EMAIL_ADDRESS"

# View Git configuration.
$ git config --list

Mac and Linux

Please run the below commands to configure the Git username and email address on the Mac or Linux operating system.

# Configure global username in Git.
$ git config --global user.name "USERNAME"

# Configure global email address in Git.
$ git config --global user.email "EMAIL_ADDRESS"

# View Git configuration.
$ git config --list