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
Section titled “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
Section titled “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"' > ~/.bashrcsource ~/.bashrc- Confirm the Git version:
git --versionMethod 2: Compile Git from Source
Section titled “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.gitcd gitmake configure./configure --prefix=$HOMEmake allmake install- Configure your shell environment to use the new executable (replace
usernamewith your account username):
echo 'alias git="/home/username/bin/git"' > ~/.bashrcsource ~/.bashrc- Verify the new Git version:
git --versionConfiguring Unmanaged Servers
Section titled “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-devAlmaLinux:
yum install git gcc autoconf perl-devel gettext- (Optional) Install packages for building Git documentation:
Ubuntu 14.04:
apt-get install asciidoc docbook2xAlmaLinux:
yum install epel-releaseyum install asciidoc xmlto docbook2Xln -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.gitcd gitmake 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-manAlmaLinux:
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 --versionThe latest Git version should display (currently 2.31.0).
More Information
Section titled “More Information”For more details about Git, visit https://git-scm.com.