INSTALL GIT ON LINUX

Hemashree S

 Install Git on Ubuntu

  • Git is a free, open-source distributed version control system designed for efficient management of projects, from small to large, and facilitates collaboration among programmers by allowing them to track and work together in a shared workspace.
  • Git is the most widely used source code management (SCM) tool, surpassing earlier version control systems like SVN. Now, let’s learn how to install Git on your Ubuntu server.

Introduction to Git

  • Git is designed with a focus on data integrity, speed, and support for non-linear, distributed workflows.
  •  It was initially developed by Linus Torvalds in 2005 for the Linux kernel, with contributions from other kernel developers, and has been maintained by Junio Hamano since then.
  • Unlike most client-server systems and similar to other distributed version control systems, every Git directory on any computer is a fully developed repository with complete version-tracking and history capabilities, independent of a central server or network access. 
  • Git is open-source software, distributed under the GPL-2.0-only license, and available for free.

Brief History of Git

In April 2005, Git development commenced after several kernel developers decided to stop using BitKeeper, the SCM system they had been employing to manage the project.
Linus Torvalds desired a distributed system similar to BitKeeper, but the existing open-source options didn't meet his needs. 
Torvalds envisioned a source control management system that could apply a patch and update all related metadata in thirty seconds, which he believed would be insufficient for the Linux kernel's development, where synchronizing with fellow maintainers might require 250 such operations at once. 
He emphasized that patching should take no more than three seconds and outlined three additional goals:
  • Incorporate robust safeguards to protect against both malicious and accidental corruption.
  • Provide support for a distributed workflow similar to that of BitKeeper.
  • Use CVS (Concurrent Versions System) as an example of what to avoid; if uncertain, choose the opposite approach.

Design of Git

Git's design was influenced by Monotone and BitKeeper. Initially, Git was developed as a low-level engine for version control, allowing others to create front ends such as StGIT or Cogito.

Characteristics

Git's design combines Linus Torvalds' experience managing a large, distributed development project with Linux, his knowledge of file-system performance from similar projects, and the need to create an efficient system. These factors led to the implementation options outlined below:
  • Non-linear development support: Git facilitates fast merging and branching and includes specialized tools for navigating and visualizing a non-linear development history. A key concept is that modifications are merged more often than they are written in Git, as they are reviewed by multiple people. In Git, branches are lightweight, essentially just references to individual commits, and a complete branch structure is constructed from its parent commits. 
  • Distributed development: Similar to Monotone, Bazaar, Mercurial, BitKeeper, and Darcs, Git gives each developer a full copy of the development history, with changes being transferred between these repositories.
  • Compatibility with legacy protocols and systems: Repositories can be accessed through the Git protocol, FTP, HTTP, or HTTPS, using either Secure Shell or a plain socket.
  • Effective management of larger projects: Torvalds has described Git as highly scalable and fast, and performance tests conducted by Mozilla demonstrated that Git is significantly faster at handling larger repositories compared to GNU Bazaar and Mercurial.
  • Cryptographic authentication of history: Git stores history in a way that the ID of a specific version depends on the entire development history leading up to that commit.
  • Toolkit-based structure: Git was initially developed as a set of programs written in C, along with numerous shell scripts serving as wrappers for these programs. However, most of these scripts have since been rewritten in C for improved portability and speed.
  • Pluggable strategies: Git features a well-defined structure for handling merges, incorporating two or more algorithms as part of its toolkit to manage merge conflicts.

Data Structures 

The core components of Git are not inherently a source-code management system. Instead, Git began with a basic set of features and has integrated and refined the full range of functionalities typical of a classic SCM over time, evolving from this initial design.
Git employs two distinct data structures. The first is a mutable index (also called the cache or stage), which stores information about the active directory and the next revision to be committed. The second is an append-only, immutable object database.

The immutable database contains five types of objects:
  1. Blob
  2. Tree
  3. Commit
  4. Tag
  5. Packfile
Git also stores labels called refs (or references) to denote the locations of various commits. These include:
  1. Heads (branches)
  2. HEAD
  3. Tags

Git Installation

I performed this installation on Ubuntu 16.04 LTS, but the commands provided should also work with other versions.
Here are the steps to install Git on an Ubuntu server:

Step 1: Start the General OS and Package update
First, we need to update the operating system and packages. To do this, run the command below.
$ apt-get update
Having started the OS and package updates, we will now perform general updates on the server to prepare for Git installation. To do this, run the following commands.

Step 2: Install Git
To install Git, use the following command:
$ apt-get install git-core
The command above will install Git on your system, but you might be prompted to confirm the download and installation.

Step 3: Confirm Git the installation
Once the installation is complete, verify that the executable file is set up and accessible by using the `git --version` command. Run it as follows:
$ git --version
Output:
git version 2.24.0

Step 4: Configure the Git for the First use
You can now start using Git on your system and explore its many features. To begin, you need to configure the initial user settings using the `git config` command.
To register a user with the username "John" and the email address "John@xyz" use the following commands:
To set the username, run the following command:
$ git config --global user.name "John"
To set the email address for the author, use the following command:
$ git config --global user.email  "John@xyz"
You have now successfully registered a user for the version control system.
It's important to note that the `git config` tool operates on a per-user basis. For example, if "john" is registered on Git, another user, "Mike," can also be registered on the same machine. To set up Mike's user details, he must run the same command from his own user account. Commits made by each user will be recorded under their respective details in Git.
For a detailed overview of the `git config` command, visit [this link].
Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send