Hey! In this post I would like to discuss about git installation on Oracle Linux. By default git from the yum repo version is older 1.8.2. To get used of the latest features of git needs to install the latest version of git. Currently, the git version is 2.30.1. But this experiment will be same further as well.
Step 1: Navigate to a path where the git installer needs to download.
cd /opt wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.30.1.tar.gz #remove the default git version from yum repo yum remove git -y # extract the git tarball tar -zxf git-2.30.1.tar.gz cd git-2.30.1
Step 2: The prerequisites for git installation is as:
# prerequisites yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel -y yum install gcc perl-ExtUtils-MakeMaker -yStep 3: Install the git version
# installing latest version of git make prefix=/usr/local/git all make prefix=/usr/local/git installStep 4: Now all set, we need to have the latest git installed directory in the PATH. setting up the PATH for all users on the Machine
# set the global path echo "export PATH=/usr/local/git/bin:$PATH" >> /etc/bashrc source /etc/bashrc git --versionStep 5: After confirmation of the latest version in the PATH. Clean up the installer and extracted folder from /opt directory.
# clean up cd /opt; rm -rf git-2.30.1 git-2.30.1.tar.gzNoq id you mix all the above snippets to form an automation script, the name of the script would be "gitinstlal.sh" and the content goes here:
#!/bin/bash # Install Git latest version on RHEL flavours # Download this script or use git clone then run regular shell script execution # ./gitinstall.sh # Created: 20-Feb-2021 # VER=2.30.1 # prerequisites echo "Install dependencies" yum install -y wget \ curl-devel expat-devel gettext-devel openssl-devel zlib-devel \ gcc perl-ExtUtils-MakeMaker cd /opt wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-${VER}.tar.gz echo "Check git installed version after dependencies installed..." git --version if [ $? -eq 0 ]; then #remove the default git version from yum repo echo "Removal of old version of git" yum remove git -y fi # extract the git tarball echo "Extracting git installer" tar -zxf git-${VER}.tar.gz cd git-${VER} # installing latest version of git echo "Compile and install git latest version" make prefix=/usr/local/git all make prefix=/usr/local/git install # set the global path echo "Adding to PATH" echo "export PATH=/usr/local/git/bin:$PATH" >> /etc/bashrc source /etc/bashrc git --version | grep ${VER} [ $? -eq 0 ] && echo "Git installed latest version successfully" # clean up echo "Clean up the git installer stuff" cd /opt; rm -rf git-${VER} git-${VER}.tar.gz
No comments:
Post a Comment