> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using a newer version of Git

> Learn how to configure and use a newer version of Git on your server. Just follow our easy, step-by-step Git Guide.

This article describes how to configure and use a newer Git version. You may want to do this if:

* You have an account on a managed server, and you need a version of Git newer than what is installed on the server.
  > 📘 Note
  >
  > This applies to all hosting accounts that have cPanel, including shared and reseller servers.

* You have an unmanaged server, and the package repositories for your Linux distribution contain an outdated version of Git.

## Configuring managed servers

Depending on the managed server where your account is located, there may be an outdated version of the Git client installed. If this is the case, there are two ways you can use a newer version of Git.

### Method #1: Use an alternate Git version

cPanel uses a newer version of the Git client for its own updates. To configure your account to use this version, follow these steps:

1. Log in to your account [using SSH](/docs/using-ssh-secure-shell).

2. At the command prompt, type the following commands:

   ```bash theme={null}
   echo 'alias git="/usr/local/cpanel/3rdparty/bin/git"' > ~/.bashrc
   source ~/.bashrc
   ```

3. To confirm your account is configured to use the new version, type the following command:

   ```bash theme={null}
   git --version
   ```

### Method #2: Compile Git from source

If you need the latest version of Git, you can compile it from the source code.

<Warning>
  **Important**

  Although we have tested and run this configuration, it is not supported. Additionally, you can only compile the Git client. Compiling the Git man pages and documentation requires packages that are not installed on managed servers.
</Warning>

To compile the Git client from source, follow these steps:

1. Log in to your account [using SSH](/docs/using-ssh-secure-shell).

2. At the command prompt, type the following commands:

   ```bash theme={null}
   cd ~
   git clone git://git.kernel.org/pub/scm/git/git.git
   cd git
   make configure
   ./configure --prefix=$HOME
   make all
   make install
   ```

3. To configure your shell environment to use the new compiled executable, type the following commands. Replace ***username*** with your own hosting.com account username:

   ```bash theme={null}
   echo 'alias git="/home/username/bin/git"' > ~/.bashrc
   source ~/.bashrc
   ```

4. To confirm your account is configured to use the new version, type the following command:

   ```bash theme={null}
   git --version
   ```

## Configuring unmanaged servers

The package repositories for your Linux distribution may contain an outdated version of Git. To use the newest version of Git, you can build it from source. To do this, follow these steps:

1. Log in to your server [using SSH](/docs/using-ssh-secure-shell).

2. As the root user, install the compilation prerequisites using the appropriate command for your Linux distribution:

   * For Ubuntu 14.04, type:

     ```bash theme={null}
     apt-get install git gcc autoconf zlib1g-dev
     ```

   * For AlmaLinux, type:

     ```bash theme={null}
     yum install git gcc autoconf perl-devel gettext
     ```

3. This step is optional. In addition to the Git binaries, you can compile and install the Git documentation. To install the prerequisites for building the documentation, use the appropriate command or commands for your Linux distribution:

   * For Ubuntu 14.04, type:

     ```bash theme={null}
     apt-get install asciidoc docbook2x
     ```

   * For AlmaLinux, type:

     ```bash theme={null}
     yum install epel-release
     yum install asciidoc xmlto docbook2X
     ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi
     ```

4. To download the Git source code and configure the build environment, type the following commands:

   ```bash theme={null}
   git clone git://git.kernel.org/pub/scm/git/git.git
   cd git
   make configure
   ./configure
   ```

   > 👍 Tip
   >
   > By downloading the Git source code using the Git client itself, it is easy to download the latest source code whenever you want.

5. To compile the Git binaries, type the following command:

   ```bash theme={null}
   make all 
   ```

   > 📘 Note
   >
   > If you want to compile the Git documentation as well, type the following command instead:
   >
   > ```bash theme={null}
   > make all doc info man
   > ```

6. To remove the Git version that you installed using the package repositories in step 2, use the appropriate command for your Linux distribution:

   * For Ubuntu 14.04, type:

     ```bash theme={null}
     apt-get purge git git-man
     ```

   * For AlmaLinux, type:

     ```bash theme={null}
     yum remove git git-man
     ```

   > 📘 Note
   >
   > Removing the version installed by the package manager helps prevent any conflicts with the Git version you compiled locally.

7. To install the compiled Git binaries, type the following command:

   ```bash theme={null}
   make install 
   ```

   > 📘 Note
   >
   > If you want to install the compiled Git documentation as well, type the following command instead:
   >
   > ```bash theme={null}
   > make install doc info man
   > ```

8. Log out of the server, and then log back in. At the command prompt, type the following command:

   ```bash theme={null}
   git --version
   ```

   Git should display the latest version (at the time this article is written, the latest version is 2.31.0).

## More information

For more information about Git, please visit [https://git-scm.com](https://git-scm.com).

## Related articles

* [Using Git](/docs/using-git)

* [Configuring a Git client](/docs/configuring-a-git-client)
