• About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap
Linux Tutorials for Beginners
Advertisement
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
No Result
View All Result

Home » Ubuntu » How To Install and Config Git on Ubuntu 22.04

How To Install and Config Git on Ubuntu 22.04

sammbysamm
October 17, 2023
Install Git on Ubuntu

How To Install and Configure Git on Ubuntu 22.04

Share on FacebookShare on LinkedinShare on Whatsapp

Introduction Git

This article provides an in-depth, step-by-step guide on how to install and config Git on Ubuntu 22.04, you to take full advantage of its capabilities and streamline your development workflows “How To Install and Configure Git on Ubuntu 22.04”.

In the realm of modern software development, version control is a foundational practice that ensures efficient collaboration, smooth code management, and a clear history of changes.

OTHER POSTS

How To Install and Secure phpMyAdmin on Ubuntu 22.04

How To Secure SSH with Fail2Ban on Ubuntu 22.04

How To Install Uptime Kuma on Ubuntu 22.04

Table of Contents

  • Introduction Git
  • Prerequisites
  • Installing Git on Ubuntu 22.04
  • Option 1: Install Git with the Default Package Manager
    • Step 1: System Update
    • Step 2: Install Git Using Apt
  • Option 2: Install Git from the Source
    • Step 1: Install Required Dependencies
    • Step 3: Compile and Install Git
  • Setting up Git on Ubuntu 22.04
    • Step 1: Add a user and email
    • Step 2: Verify Configuration
  • Conclusion

Git, a distributed version control system, has revolutionized the way developers work by enabling seamless tracking of changes and collaborative coding. Version control is at the heart of effective software development. It allows developers to track changes to their codebase, work simultaneously on the same project, and revert to previous states if necessary.

Git’s decentralized architecture takes version control a step further by enabling developers to work offline, merge changes effortlessly, and collaborate seamlessly. These practices not only enhance development efficiency but also contribute to better code quality and project management.

Prerequisites

Before we dive into the installation process, there is prerequisite you need to ensure are in place:

  • Ubuntu Server: Make sure you have a clean installation of Ubuntu Server (Initial Setup Ubuntu Server 22.04) ready to go. You can deploy this on a physical machine or a virtual environment like VMware or VirtualBox.

Installing Git on Ubuntu 22.04

With Git, you can go back to a particular time and undo changes. With this, you’d agree that Git is a valuable tool under your belt; let’s get on to see how to install git on Ubuntu 22.04!

In this tutorial you will learn:

  • How to install Git
  • How to set global username
  • How to set global email
  • How to check git version

There are two basic methods to get Git up and running Ubuntu 22.04: using the Ubuntu package manager or downloading the official Git distribution. Let’s look at them briefly:

  • Package Manager: A package manager lets you install software directly from the Ubuntu software repositories. This method guarantees easy maintenance and updates through the package management system.
  • Official Git Distribution: Alternatively, you can choose to download and install the official Git distribution directly from the Git project’s website. This method provides the latest version of Git with all its features and enhancements.

Based on your needs, you can use any of the methods.

Option 1: Install Git with the Default Package Manager

Installing Git with a package manager like apt offers you ease of installation; it also allows you easily manage and update Git. The version of Git you get with this method may not be the latest version.

Ubuntu 22.04 should have git installed by default. Run the following command to check if you have git installed:

samm@git:~$ git --version
git version 2.34.1

You can install Git using the following steps with apt :

Step 1: System Update

Before installing any packages, run the apt command below to update and refresh your Ubuntu repository.

samm@git:~$ sudo apt update

Step 2: Install Git Using Apt

Next, install git using apt by running the following command:

samm@git:~$ sudo apt install git

Once the installation is complete, you can start running git commands from the terminal.

Option 2: Install Git from the Source

This method How to Install Git in Ubuntu, though not as simple as the first method, will provide you with the latest version of Git.

Step 1: Install Required Dependencies

Install the dependencies using the following code:

samm@git:~$ sudo apt install libz-dev libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext cmake gcc

Output:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'zlib1g-dev' instead of 'libz-dev'
gcc is already the newest version (4:11.2.0-1ubuntu1).
gcc set to manually installed.
libexpat1-dev is already the newest version (2.4.7-1ubuntu0.2).
libexpat1-dev set to manually installed.
zlib1g-dev is already the newest version (1:1.2.11.dfsg-2ubuntu9.2).
zlib1g-dev set to manually installed.
The following additional packages will be installed:
  cmake-data dh-elpa-helper libjsoncpp25 librhash0
Suggested packages:
  cmake-doc ninja-build cmake-format gettext-doc autopoint libasprintf-dev libgettextpo-dev libcurl4-doc libgnutls28-dev libidn11-dev libkrb5-dev libldap2-dev librtmp-dev libssh2-1-dev libssl-doc
The following NEW packages will be installed:
  cmake cmake-data dh-elpa-helper gettext libcurl4-gnutls-dev libjsoncpp25 librhash0 libssl-dev
0 upgraded, 8 newly installed, 0 to remove and 66 not upgraded.
Need to get 10.8 MB of archives.
After this operation, 48.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

At some point, you’ll be asked if you would like to continue, type “Y” to indicate yes and press enter.

Step 2: Download the Git Source Code

Once the packages have been installed, you can go on to download Git. You can get the download link for the latest version from the download page.

To download the latest version of Git as at the time of this writing, run the following code:

samm@git:~$ wget https://www.kernel.org/pub/software/scm/git/git-2.41.0.tar.gz -O git.tar.gz

Output :

--2023-08-06 05:25:36--  https://www.kernel.org/pub/software/scm/git/git-2.41.0.tar.gz
Resolving www.kernel.org (www.kernel.org)... 145.40.73.55, 2604:1380:40e1:4800::1
Connecting to www.kernel.org (www.kernel.org)|145.40.73.55|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.41.0.tar.gz [following]
--2023-08-06 05:25:36--  https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.41.0.tar.gz
Resolving mirrors.edge.kernel.org (mirrors.edge.kernel.org)... 147.75.48.161, 2604:1380:40f1:3f00::1
Connecting to mirrors.edge.kernel.org (mirrors.edge.kernel.org)|147.75.48.161|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10791798 (10M) [application/x-gzip]
Saving to: ‘git.tar.gz’

git.tar.gz                                           100%[=====================================================================================================================>]  10.29M   293KB/s    in 35s     

2023-08-06 05:26:12 (299 KB/s) - ‘git.tar.gz’ saved [10791798/10791798]

This will download the git source code archive for version 2.41.0 and save it as git.tar.gz in the current directory.

After Git has been downloaded, extract the contents of the file using:

samm@git:~$ tar -zxf git.tar.gz

Step 3: Compile and Install Git

Next, change from the current directory to the extracted git source code directory by running the following in the terminal:

samm@git:~$ cd git-2.41.0/

Once in the extracted git source code directory, you can proceed with the installation of Git. Run the following commands to compile the git source code and install git and also restart the bash shell to save the changes and ensure that the changes are reflected in the current shell session.

Setting up Git on Ubuntu 22.04

Once Git is installed, it is recommended that you make some configurations. In particular, the identification associated with your commits. Rather than having to make this configuration for each repository, it’s possible to make a global configuration using a .gitconfig file located in the root folder of the home user.

Install and Configure Git on Ubuntu
Platforms Repositories GitLab

Step 1: Add a user and email

You can add a global username and email address for Git on your system by running the following:

This file can be made manually or by using the config option with the git command:

git config --global user.name "Firstname Lastname" git config --global user.email "[email protected]"

samm@git:~$ git config --global user.name "tech_sammlinux"
samm@git:~$ git config --global user.email "[email protected]"

Adding these settings will establish consistent authorship across your Git repositories. It helps identify who made specific changes and enables proper collaboration and communication within a team or open-source community.

Step 2: Verify Configuration

Display your .gitconfig file in your home directory:

samm@git:~$ cat .gitconfig

Output :

[user]
	email = [email protected]
	name = tech_sammlinux

Step 3: Git Initialization

You can initialize an existing project folder or make a new directory to initialize Git inside it. create a new directory with mkdir command.

samm@git:~$ mkdir TUTORIAL

Get inside that folder by issuing the following command:

samm@git:~$ cd TUTORIAL/
samm@git:~/TUTORIAL$

The following command will initialize the Git repository in the “TUTORIAL” directory:

samm@git:~/TUTORIAL$ git init

Output :

hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint: 	git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint: 	git branch -m <name>
Initialized empty Git repository in /home/samm/TUTORIAL/.git/

The output shows that the Git repository has been initialized in the “TUTORIAL” directory.

Let’s check the status of Git inside the “TUTORIAL” directory.

samm@git:~/TUTORIAL$ git status

Output :

On branch master

No commits yet

nothing to commit (create/copy files and use "git add" to track)

The command shows that the Git is working inside the “TUTORIAL” and there are no commits encountered yet.

After doing so, you can observe the changes in the Git configuration list as follows:

samm@git:~$ git config --list

Output :

/home/samm/TUTORIAL
[email protected]
user.name=samuelsiahaan

Conclusion

You’ve successfully installed and configured Git on your Ubuntu 22.04 system. Git is now ready for use, allowing you to manage and track changes in your projects effectively. Whether you’re a developer, a student, or someone interested in version control, Git is an essential tool that can simplify and enhance your workflow. Start using Git today to keep track of your project’s history and collaborate seamlessly with others. Happy coding!

Also Read Our Other Guides :

  • How To Install Jenkins on Ubuntu 22.04
  • How To Use Git Version Control on Linux: For Beginner
  • How To Install VirtualBox 7.0 on Ubuntu 22.04
  • How To Install Vagrant on Ubuntu 22.04
  • How To Install and Configure Ansible on Rocky Linux 9
  • How To Create AWS CloudFront: A Step-by-Step Guide
  • How To Install Python 3.11 from Source on Ubuntu 22.04
  • How To Install Python 3.11 on Rocky Linux 9

Finally, now you have learned How To Install and Config Git on Ubuntu 22.04.

Tags: DevOpsGitGithubGitlabRepositoryUbuntuVersion Control

If you got help by our tutorials, please buy me a coffee..!

Buy Me a Coffee

Thank you so much for your support!!

Previous Post

How To Install and Use Docker CE on Ubuntu 22.04

Next Post

How To Install Vagrant on Ubuntu 22.04

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RECENT POST

Install and Secure phpMyAdmin on Ubuntu 22.04

How To Install and Secure phpMyAdmin on Ubuntu 22.04

by samm
July 22, 2024
0

Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we'll walk you...

Manage Groups on Linux

A Simple Guide: How To Manage Groups on Linux

by samm
November 12, 2023
0

Are you a Linux enthusiast looking to enhance your system administration skills? One fundamental aspect you should master is how...

Install phpMyAdmin on Rocky Linux 9

How To Install phpMyAdmin on Rocky Linux 9

by samm
November 11, 2023
0

If you're navigating the world of Rocky Linux 9 and looking to streamline your MariaDB or MySQL database management, installing...

Logrotate In Linux

How To Manage Log Files Using Logrotate In Linux

by samm
November 10, 2023
0

Log files are an essential part of any Linux system. They provide valuable insights into the system's activities, helping administrators...

Load More

RECOMMENDED.

Install Redis on Debian

How To Install Redis on Debian 11 Server

October 16, 2023
Secure SSH with Fail2Ban

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
sammlinux sammlinux sammlinux

Related Posts

Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu

How To Install and Secure phpMyAdmin on Ubuntu 22.04

July 22, 2024
Secure SSH with Fail2Ban
Ubuntu

How To Secure SSH with Fail2Ban on Ubuntu 22.04

October 29, 2023
Install Uptime Kuma on Ubuntu 22.04
Ubuntu

How To Install Uptime Kuma on Ubuntu 22.04

November 12, 2023
Install Ubuntu Server 22.04
Ubuntu

How To Install Ubuntu Server 22.04 LTS with Screenshots

October 21, 2023
Load More
Next Post
Install Vagrant on Ubuntu

How To Install Vagrant on Ubuntu 22.04

  • About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap

© 2023 sammlinux - Learn Today for Lead Tomorrow.

No Result
View All Result
  • Ubuntu
  • Debian
  • Rocky Linux
  • CentOS
  • Linux

© 2023 sammlinux - Learn Today for Lead Tomorrow.