To install and configure Git Bash on your Ubuntu 22.04 system, you can use two simple ways, first from the official repository and second using the source code.
Here are two approaches to installing git on Ubuntu 22.04 system:
- Approach 1: Using Official Repository
- Approach 2: Using Source
Approach 1: Using Official Repository
Here are steps for installing git on ubuntu 22.04 using official repository:
Step 1 – Update System
Type this command on terminal window to update the latest dependencies on system:
sudo apt update
Step 2 – Install Git on Ubuntu 22.04 using Official Repository
Now you can install Git on the latest Ubuntu using the official repository, for this you have to type the command on the terminal:
sudo apt install git
Approach 2: Using Source Code
Here are steps for installing git on ubuntu 22.04 using source:
Step 1 – Install Required Packages
Before installing Git from source code, this related package needs to be installed in ubuntu, for this you can use:
sudo apt install libz-dev libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext cmake gcc
Step 2 – Download Git Source Code
Now you can install Git from source code in your system, for this you have to type the command on the terminal:
wget https://www.kernel.org/pub/software/scm/git/git-2.40.1.tar.gz -O git.tar.gz
Step 3 – Extract the Downloaded Git Source code
Now extract the downloaded git source code archive, you can do this with this command:
tar -zxf git.tar.gz
Step 4 – Install Git on Ubuntu 22.04 using Source Code
Now the enter to extract git directory with the help of command this command:
cd git-*
Then type this command on terminal windows, to install git:
# Compile Git with the specified sudo make prefix=/usr/local all # Install Git with the specified prefix sudo make prefix=/usr/local install # Restart the bash shell to ensure changes take effect exec bash
Configure Git on Ubuntu 22.04
Here are steps for configure git on ubuntu 22.04:
Step 1 – Configure Git
To configure Git to assign a username and email, you can use this command:
$ git config --global user.name "Tutsmake" $ git config --global user.email "[email protected]"
Step 2 – Confirm the Changes
Finally, run the last command on terminal window to list global git settings to confirm your git configuration:
$ git config --list
Here is the video guide for installing and configuring git on ubuntu 22.04:
Conclusion
Through this tutorial, you have learned two simple ways to install Git on ubuntu 22.04 using the apt package manager and source code.