Installing Git.

Or: A Tool for Cloning GitHub Repos... Oh, and Version Management.

Installing Git.

TL;DR.

This post provides a comprehensive guide on how to install Git, a popular version control system. It explains Git's functionalities and the various states that files can reside in when using Git. Then the guide moves the reader through installing Git on a Debian-based Linux distribution, covering multiple install methods, including building Git from source, installing it from a PPA repo, or using a modified APT command. This post also provides a way to check the installed version of Git.

Attributions:

https://git-scm.com/ ↗, and

https://www.geeksforgeeks.org/how-to-install-configure-and-use-git-on-ubuntu/ ↗.

An Introduction.

Git is a version control system. During development, Git is responsible for managing changes to the source code of computer programs, large web sites, and documents.

The purpose of this post is to present different ways of installing Git.

The Big Picture.

Git views its data as a series of snapshots. When I commit or save my project's state, Git takes a "picture" of how my files look at that moment and saves a reference to that snapshot. To save space, if files haven't changed, Git doesn't store the file again but links to the previous identical file it already saved.

Most Git actions only involve local files and don't require information from other computers on my network. Git seems incredibly fast since I usually have the whole project history on my local disk.

Git checks every file and folder and generates a unique checksum before saving everything. This checksum is then used to refer to the files and folders. This means I can't change the contents of any file without Git knowing because the checksums wouldn't match. This feature is a core part of Git's design, so I won't lose any data or have corrupted files without Git noticing.

When I perform actions in Git, almost all of them just add data to the Git database. It's difficult to make the system do something that can't be undone, or make it erase data without leaving a way back to a previous state. Yes, I can lose or mess up uncommitted changes, but once I commit to Git, it's hard to lose any changes, especially if I often push to another repository.

Git has three main states that my files can reside in:

  • Modified means that I have changed the content of a file(s) but have not committed it/them to my database yet.

  • Staged means that I have marked modified files in their current state to go into my next commit snapshot.

  • Committed means that the staged data has been safely moved into my local database.

If a file is in the Git directory, it is committed. If the file has been changed and added to the staging area, it is staged. If the file was changed after being checked out but hasn't been staged yet, it is modified.

Prerequisites.

  • A Debian-based Linux distro (I use Ubuntu).

Finding the Latest Version.

  • I update my system:
sudo apt clean && sudo apt update && sudo apt dist-upgrade -y && sudo apt --fix-broken install && sudo apt autoremove -y
  • I visit the GitHub repo to find the latest version number:
https://github.com/git/git/tags

Installing the Prerequisites.

  • I install the prerequisites:
sudo apt install -y libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev build-essential
  • I install wget:
sudo apt install -y wget
  • I install autoconf:
sudo apt install -y autoconf

Building Git.

  • I use wget to download the latest version of Git:
wget https://github.com/git/git/archive/refs/tags/v2.43.0.tar.gz
  • I use tar to extract the archive:
tar -xvf v2.43.0.tar.gz
  • I list the name of the extracted directory:
ls
  • I change to the new directory:
cd ./git-2.43.0
  • I configure the build:
make configure
  • I set up the script:
./configure --prefix=/usr/local
  • I compile the source code:
make all
  • I install Git:
sudo make install
  • I check the version of Git:
git --version

Alt: Installing Git from the PPA Repo.

  • I install the PPA (personal package archive) repo:
add-apt-repository ppa:git-core/ppa
  • I update my system:
sudo apt clean && sudo apt update && sudo apt dist-upgrade -y && sudo apt --fix-broken install && sudo apt autoremove -y
  • I install Git:
sudo apt install git

Alt: Installing Git the Easiest Way.

  • I use APT to install Git:
sudo apt install git
sudo apt install git-all

To Be Continued...

Installing Git is the start of a more important process: Version control. TBC.

The Results.

Git is an essential tool for managing changes in source code during development. Its unique design, which involves taking snapshots of files and generating checksums, ensures data integrity and makes it difficult to lose or corrupt data. This guide has walked through several ways to install Git on a Debian-based Linux distribution, including building from source, using a PPA repository, and using a modified APT command. Whichever method I choose, understanding and utilizing Git is the first step towards efficient version control. Git's power lies in its ability to track and manage changes, ensuring that nothing is lost during development.

In Conclusion.

Are you looking to install a popular version control system called Git?

Git is a powerful tool that manages changes to my source code during development. Its ability to take "snapshots" of my files and generating checksums for data integrity, makes it nearly impossible to lose or corrupt my data. If you're in software development, you know how crucial version control is to an effective workflow.

Git is designed with three main states for my files: Modified, Staged, and Committed. Understanding these states is the first step towards mastering Git.

Regardless of the method you choose to install Git, remember that it is more than just a tool. It's the first step towards efficient version control.

Have you used Git before? How has it transformed your development process? Share your thoughts below.

Until next time: Be safe, be kind, be awesome.

NOTE: All images generated by ComfyUI using the sd_xl_base_1.0 checkpoint.