Customer Support

  1. Support
  2. How to install Git on Ubuntu, Debian, CentOS, macOS, and Windows
  1. Home
  2. Dedicated / VPS Management
  3. How to install Git on Ubuntu, Debian, CentOS, macOS, and Windows

How to install Git on Ubuntu, Debian, CentOS, macOS, and Windows

Git is one of the most widely used open-source version control systems. It allows you to manage code, collaborate with other developers, and track changes to your files safely and efficiently. Below is a detailed, knowledge-base-ready guide based on the official Git documentation explaining how to install and configure Git across different operating systems.


What is Git?

Git is a distributed version control system (DVCS). Unlike centralized systems, each developer has a full copy of the repository — including all history and branches. This makes it fast, secure, and reliable for projects of any size.

  • Work locally: You can work offline without depending on a central server.
  • Clone: Copy an entire repository with its history.
  • Commit & Branching: Record changes and create isolated branches for testing or new features.
  • Merge: Combine different branches safely and efficiently.

Installing Git on Linux

Most Linux distributions include Git in their default repositories. You can install it directly using your package manager.

Ubuntu / Debian

sudo apt update sudo apt install git

Verify that the installation completed successfully:

git --version

To install the latest available Git version, add the official Git PPA repository:

sudo add-apt-repository ppa:git-core/ppa sudo apt update sudo apt install git

Fedora

sudo dnf install git

CentOS / AlmaLinux / Rocky Linux

On CentOS 8 and later, use dnf instead of yum:

sudo dnf install git

For older releases (CentOS 7):

sudo yum install git

Arch Linux

sudo pacman -Sy git

Installing Git on macOS

There are several ways to install Git on macOS.

1. Using Xcode Command Line Tools

Run the following command in the Terminal:

xcode-select --install

A dialog window will appear; follow the prompts to complete the installation. Once done, Git will be available system-wide.

2. Using Homebrew

If you use Homebrew, simply run:

brew install git

3. Using the official installer

Download the official macOS installer from git-scm.com/download/mac and follow the on-screen instructions.


Installing Git on Windows

The easiest way to install Git on Windows is through the Git for Windows installer, which includes both command-line and graphical tools.

1. Download the installer

Go to git-scm.com/download/win and download the latest version for Windows.

2. Run the installer

You can generally keep the default settings unless you have specific requirements. The installer will include:

  • Git Bash â€” a Unix-style command-line environment.
  • Git GUI â€” a graphical interface for commits, branches, and merges.
  • Windows Explorer integration â€” context menu options for Git commands.

After installation, open Git Bash and verify it’s installed correctly:

git --version

If you see a version number (e.g. git version 2.45.1.windows.1), your setup was successful.


Post-installation configuration

After installing Git, configure your name and email address. These details are included in your commits and identify you as the author.

git config --global user.name "Your Name" git config --global user.email "you@example.com"

To verify your settings:

git config --list

You can also set your preferred text editor (for example, Nano or Vim):

git config --global core.editor "nano"

Enable colored output for better readability in the terminal:

git config --global color.ui auto

Testing your Git installation

Create a test directory and initialize a new repository to confirm Git works correctly:

mkdir git-test cd git-test git init

If you see the message:

"Initialized empty Git repository in /home/user/git-test/.git/"

then Git is installed and working properly.


Common issues

  • Git not recognized: Restart your terminal or ensure Git’s path was added to your environment variables.
  • Clone errors: Verify your repository URL and permissions (HTTPS or SSH).
  • Invalid commit author: Check your name and email settings with git config --list.

Conclusion

You have now successfully installed and configured Git. You can start creating repositories, making commits, and collaborating with other developers using platforms such as GitHub or GitLab. Git is an essential tool for every development workflow.


You haven't found what you are looking for?

Contact our experts, they will be happy to help!

Contact us