- Check for Git exists
- Install Git
- Confirm Git Installation
Pick an instance on Cloud or online terminal of Ubuntu 20+ version to this experiment. Here I'm using the KillerCoda provided Ubuntu.
Check for Git exists
This is a common requirement when you join a new project and on the Linux machine you would like to know git installed or not. We have couple of options to check it. Let's do it here:
dpkg -l git #or dpkg --list gitIn the output first 'ii' in the list means (if there are packages installed, you should see this mark) that the package is correctly installed and available. alternatively you can also try other option to check git installation on Ubuntu.
apt list git #or apt list git -aOr else you can simply use `git` it will works and provides git command help when git already installed.
gitWe can see that it is not the latest version as of now, So I wish to get the latest git version on Ubuntu.
Install Git
1. we will download our desired verison of Git tarball, untar it, enter into the extracted directory. 2. Build the source code using make 3. Run the installation using make install
# install pre-requisite libraries sudo apt update sudo apt install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip # Download your desired version wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.48.1.tar.gz tar -zxf git-*.tar.gz cd git-2.48.1 make prefix=/usr/local all sudo make prefix=/usr/local installNow Build steps
Confirm Git Installation
You know already multiple ways ot check git existing on your Ubuntu. Let's quickly validate it with `--version` opton.
git --version
Auomation in mind
Power of your brain should work smart when you look at this instructions any AI tool can gives these but we have God's given our own brain to use :)
#!/bin/bash SECONDS=0 GIT_VERSION="2.48.1" if ! sudo apt update; then echo "Failed to update package list" exit 1 fi rm -rf git* sudo apt install -y make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-$GIT_VERSION.tar.gz tar -zxf git-*.tar.gz cd git-$GIT_VERSION pwd make prefix=/usr/local all sudo make prefix=/usr/local install git --version git --version | grep ${GIT_VERSION} [ $? -eq 0 ] && echo "Git installed latest version successfully!" echo "Execution time: $SECONDS seconds"
No comments:
Post a Comment