Saturday, November 16, 2024
Google search engine
HomeGuest BlogsHow to Update Git

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 GitHow 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 promptChecking 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 LinuxInstalling 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 installingChecking 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 promptUpdating 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

RELATED ARTICLES

Most Popular

Recent Comments