How to Update Git

Introduction

Git is a version control system that allows multiple developers to work on the same project while tracking changes and revisions. Keeping Git up to date brings you the latest features and usability improvements.

In this tutorial, you will learn how to update to the latest version of Git on Linux, Windows, and macOS.

How to update Git

Prerequisites

  • A system running Linux, Windows, or macOS
  • An installed version of Git
  • Access to the terminal window (Linux, macOS) or command prompt (Windows)
  • An account with administrator-level privileges

How to Check the Current Git Version?

To check the current version of Git, use the following command:

git --version

This command works on all operating systems. This example uses Windows:

Checking the current version of Git using the Windows command prompt

How to Update Git

Below, we list different ways you can update your version of Git, depending on the operating system you are using. Skip to the section applicable for your machine.

Update Git on Linux

Note: To update Git on a Linux machine, use the appropriate package manager. When working with Git on CentOS, use a package manager such as yum or pacman.

This example shows how to update Git on Ubuntu.

Start by updating the system packages with the following command:

sudo apt-get update

Update Git by using:

sudo apt-get install git

When prompted, type Y and press Enter to confirm the installation.

Installing the latest version of Git on Linux

To verify the installation has completed, check the Git version one more time:

git --version
Checking the current Git version after installing

Another way to update Git on Linux is to install it from scratch using the original source code. Check out our guide to installing Git on Ubuntu for details.

Update Git on Windows

The method you use to update Git on Windows depends on the version of Git you are currently running.

For versions prior to 2.14.1, uninstall Git from your system and install a copy of the latest version from scratch. Check out our guide to installing Git on Windows for more details.

For versions from 2.14.2 to 2.16.1, use the following command in your command prompt:

git update

For versions 2.16.1 on, update Git with:

git update-git-for-windows
Updating Git using the Windows command prompt

The output above appears when you are running the latest Git version.

Update Git on Mac

The easiest way to update Git on Mac is to use the official installer. Download the installation file from the Git website. Run the installation and follow the install wizard to update Git to the latest version.

Note: Using the install wizard to update Git overwrites the current installation.

Another method is to update Git using Homebrew. If you don't have Homebrew already, install it by using:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Update Homebrew to make sure you have the latest installation packages:

brew update

Install the latest version of Git with Homebrew:

brew install git

If you already have Git installed using Homebrew, update to the latest version with:

brew upgrade git

Check the current Git version to confirm the update:

git --version

Note: If checking the Git version after updating results in an output that includes (Apple Git-101), your system is still running the default Apple version of Git instead of the official one. Change your local path to the Homebrew version of Git to fix this issue:
export PATH=/usr/local/bin:$PATH

Conclusion

After following this tutorial, you should have a fully updated version of Git installed on a Linux, Windows, or macOS machine.

Take a look at our Git Commands Cheat Sheet for a comprehensive primer on working with Git. If you come across a Git merge conflict, make sure to read our article How to Resolve Merge Conflicts in Git.

Was this article helpful?
YesNo
Aleksandar Kovačević
With a background in both design and writing, Aleksandar Kovacevic aims to bring a fresh perspective to writing for IT, making complicated concepts easy to understand and approach.
Next you should read
Git Commands Cheat Sheet
March 10, 2020

Git, the popular version control system, has a plethora of commands for managing your project history. This article lists out all the important commands every developer will need at some point.
Read more
How to Delete a Git Branch Remotely and Locally
October 13, 2020

This article provides a quick overview of basic commands and processes necessary for deleting both local and remote Git branches.
Read more
How To Switch Branch on Git
February 3, 2020

Developers need to switch between branches frequently. Git branches allow you to work on your code, fix bugs, or develop new features in a way that does not affect applications running in production.
Read more
How To Unstage Files on Git
September 15, 2020

Unstaging in Git means removing queued changes from the index. This guide covers several different ways to unstage changes.
Read more