Help

How to Build the Latest Git from Source

Step 1: Install dependencies

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

Step 2: Download and extract the Git source code


cd /opt
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.40.0.tar.gz
tar -zxf git-2.40.0.tar.gz

Step 3: Build and install Git

cd git-2.40.0 
make prefix=/usr/local/git all 
make prefix=/usr/local/git install

Step 4: Add Git to the PATH environment variable

echo "export PATH=/usr/local/git/bin:$PATH" >> ~/.bashrc 
source ~/.bashrc

Adding this line to the ~/.bashrc file adds the path to the installed Git to your PATH variable, so the newly installed version of Git is used when you run commands from the command line.

Once Git 2.40.0 is installed, you can check its version with the following command:

git --version

If Git was installed successfully, the output of this command will show version 2.40.0.

Have more questions about Hosting?