This article describes how to configure and use a newer Git version. You may want to do this if:
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.
cPanel uses a newer version of the Git client for its own updates. To configure your account to use this version, follow these steps:
echo 'alias git="/usr/local/cpanel/3rdparty/bin/git"' >> ~/.bashrc source ~/.bashrc
To confirm your account is configured to use the new version, type the following command:
git --version
If you need the latest version of Git, you can compile it from the source code.
To compile the Git client from source, follow these steps:
cd ~ git clone git://git.kernel.org/pub/scm/git/git.git cd git make configure ./configure --prefix=$HOME make all make install
To configure your shell environment to use the new compiled executable, type the following commands. Replace username with your own A2 Hosting account username:
echo 'alias git="/home/username/bin/git"' >> ~/.bashrc
source ~/.bashrc
To confirm your account is configured to use the new version, type the following command:
git --version
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:
apt-get install git gcc autoconf zlib1g-dev
For AlmaLinux, type:
yum install git gcc autoconf perl-devel gettext
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:
apt-get install asciidoc docbook2x
For AlmaLinux, type:
yum install epel-release yum install asciidoc xmlto docbook2X ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi
To download the Git source code and configure the build environment, type the following commands:
git clone git://git.kernel.org/pub/scm/git/git.git cd git make configure ./configure
To compile the Git binaries, type the following command:
make all
If you want to compile the Git documentation as well, type the following command instead:
make all doc info man
To remove the Git version that you installed using the package repositories in step 2, use the appropriate command for your Linux distribution:
apt-get purge git git-man
For AlmaLinux, type:
yum remove git git-man
To install the compiled Git binaries, type the following command:
make install
If you want to install the compiled Git documentation as well, type the following command instead:
make install doc info man
Log out of the server, and then log back in. At the command prompt, type the following command:
git --version
Git should display the latest version (at the time this article is written, the latest version is 2.7.0).
For more information about Git, please visit https://git-scm.com.
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.