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:
-
Log in to your account using SSH.
-
Run the following commands:
echo 'alias git="/usr/local/cpanel/3rdparty/bin/git"' > ~/.bashrc
source ~/.bashrc
-
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.
-
Log in to your account using SSH.
-
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
-
Configure your shell environment to use the new executable (replace
usernamewith your account username):
echo 'alias git="/home/username/bin/git"' > ~/.bashrc
source ~/.bashrc
-
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.
-
Log in to your server using SSH.
-
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
-
(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
-
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
-
Compile the Git binaries:
make all
-
To compile the binaries and documentation, run:
make all doc info man
-
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
-
Install the compiled Git binaries:
make install
-
To install with documentation, run:
make install doc info man
-
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.