Using a Newer Version of Git

Learn how to configure and use a newer version of Git on your account or server. This may be necessary if:

  • Your account on a managed server requires a Git version newer than what is installed.

  • You have an unmanaged server and your Linux distribution's package repositories contain an outdated Git version.


Configuring Managed Servers

If a managed server has an outdated Git client, you can use one of these methods:

Method 1: Use an Alternate Git Version

cPanel includes a newer Git client for its own updates. To use it:

  1. Log in to your account using SSH.

  2. Run the following commands:

echo 'alias git="/usr/local/cpanel/3rdparty/bin/git"' > ~/.bashrc
source ~/.bashrc
  1. Confirm the Git version:

git --version

Method 2: Compile Git from Source

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

Important: This method is not officially supported on managed servers. Only the Git client is compiled; documentation requires additional packages not installed on managed servers.

  1. Log in to your account using SSH.

  2. Run the following commands:

cd ~
git clone git://git.kernel.org/pub/scm/git/git.git
cd git
make configure
./configure --prefix=$HOME
make all
make install
  1. Configure your shell environment to use the new executable (replace username with your account username):

echo 'alias git="/home/username/bin/git"' > ~/.bashrc
source ~/.bashrc
  1. Verify the new Git version:

git --version

Configuring Unmanaged Servers

If your Linux distribution's package repositories contain an outdated Git version, you can compile the latest version from source.

  1. Log in to your server using SSH.

  2. Install compilation prerequisites as root:

Ubuntu 14.04:

apt-get install git gcc autoconf zlib1g-dev

AlmaLinux:

yum install git gcc autoconf perl-devel gettext
  1. (Optional) Install packages for building Git documentation:

Ubuntu 14.04:

apt-get install asciidoc docbook2x

AlmaLinux:

yum install epel-release
yum install asciidoc xmlto docbook2X
ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi
  1. Download the Git source and configure the build environment:

git clone git://git.kernel.org/pub/scm/git/git.git
cd git
make configure
./configure
  1. Compile the Git binaries:

make all
  • To compile the binaries and documentation, run:

make all doc info man
  1. Remove the Git version installed by the package manager to prevent conflicts:

Ubuntu 14.04:

apt-get purge git git-man

AlmaLinux:

yum remove git git-man
  1. Install the compiled Git binaries:

make install
  • To install with documentation, run:

make install doc info man
  1. Log out and back in, then check the version:

git --version

The latest Git version should display (currently 2.31.0).


More Information

For more details about Git, visit https://git-scm.com.

Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution