Git Version Control System : A Descriptive Guide

Safalta Expert Published by: Aryan Rana Updated Mon, 12 Dec 2022 10:59 PM IST

Highlights

Git is a version control tool, and I'll be discussing it in this article. What has now happened is that we have made git complicated by obviously not grasping its foundations. It's just git push and git pull for us. The majority of the time, we have merge conflicts and become stuck, yet occasionally it works.

Free Demo Classes

Register here for Free Demo Classes

Please fill the name
Please enter only 10 digit mobile number
Please select course
Please fill the email
Something went wrong!
Download App & Start Learning
Table of Content
Git Repository
Creating a repository in Git
Git init
Git clone
Git Status



I'll be discussing the version control tool Git in this article. What has now happened is that we have made Git complicated because we obviously don't understand the basics of this technology. We just use git push and git pull. It occasionally works, however, the majority of the time we get merge conflicts and become stuck. This was the situation for me, at least.

Source: Safalta.com

So I made the decision to finally understand this incredible tool, and that made everything apparent. So let's begin. Click here to enrol and learn from the digital marketing course.

Between Git and Github, there is now a distinction. GitHub is a service that hosts Git projects, allowing developers to seamlessly communicate while working on a project. Git is a version control tool.

Download these FREE Ebooks:
1. Introduction to Digital Marketing
2. Website Planning and Creation



There are two basic categories for version control systems. The centralised model is one, and the dispersed model is another.

Every interaction in the centralised approach must go through this one large, powerful computer that houses the project. The developers engaged in the same project are represented by the boxes that resemble computers. While there is no central computer and every developer has a copy of the project in its entirety in the distributed approach, They can now work offline on a specific project feature in this instance as well.

Every developer has a complete copy of the project thanks to the distributed version control technology known as Git.

Here are a few significant words from the language of Git. As we discuss each one of them, keep coming back to these. You can now quickly scan them.

Source code manager (SCM) or version control system (VCS): A VCS enables you to, among other things, roll back changes made over time, see who most recently changed something that might be causing a problem, who first introduced an issue and when, and more.

Commit(Snapshot): Git views its data as a collection of copies of a small file system. Every time you commit, or save the current state of your project in Git, it essentially takes a snapshot of the state of all your files at that same instant and stores a reference to that snapshot.

Repository (Repo): A directory containing your project work as well as a few files that are often hidden on Mac OS X but are necessary for Git communication. Repositories may be present locally on your computer or remotely on a different machine.

Working Directory: Your computer's file system's visible files. The files in the Working Directory are what you work with when you open your project files in a code editor.

In contrast, the repository contains files that have been saved(in commits!)

The working directory used while using Git is also distinct from the idea of the current working directory used when using the command line, which is the directory that your shell is currently "looking at."

Checkout: The process of copying content from the repository to the Working Directory. There are numerous items that can be checked out from a repository, including files, commits, branches, etc.

Staging Area, Staging Index, or Index: A file in the Git directory that contains details about the content of your upcoming commit. A staging area is similar to a prep table where Git will place the subsequent commit. The staging Index contains files that are about to be added to the repository.

SHA: Each commit's SHA essentially serves as an ID number. It is a 40-character string that is made up of the letters and numbers 0 through 9, as well as the letters a through F, and is determined using the Git file or directory contents. The acronym "SHA" stands for "SHA hash". An SHA might appear as follows:

e2ad8ae3e2e4ed40add75cc44cf9d0a869afeb6

Branch: A branch is a fresh line of development that splits off from the main path of development. Without changing the primary course of development, an alternative line can go on.


Git Repository

The working directory, the staging index, and the repository—where all the commits are saved—can be thought of as the three primary areas of a git repository.

Let's say we now have three brand-new files in our working directory. JS, CSS, and HTML files. We must first add these files to the staging index in order to save their current states. We add them to the repository from the staging index, preserving the files' present state. Soon, we will see the orders to carry out that.

We now modify the CSS file once more, stage it, and add it to the repository.

We can see that the repository is keeping track of these modifications. Git thus takes a snapshot of the altered files with each commit and keeps it in the repository. Each commit is given a 7-digit commit ID, which corresponds to the first seven digits of the 40-digit SHA. A specific commit is identified by its commit id.


Creating a repository in Git

The three commands we'll be covering in this section are. Git clone, Git status, and Git init.


Git init

git init

This command performs the following actions in the shell while in the working directory you want to track with Git:-
  • It creates all the directories and files required for Git to track everything.
  • These files are all kept in the. git directory.
  • The "repo" that we have been referring to is located in the. git directory. This is where Git keeps track of everything and records all commits.
The graphic below depicts the directory's structure.


Git clone

git clone URL

You must copy a project from the web when you need to work on one that is not already on your computer or when you wish to contribute to an open-source project. Now the project's URL may be easily obtained whether it is hosted on GitHub or Bitbucket. The repository is then fully replicated on your PC when you run the aforementioned command.


The folder's name is automatically the same as the one you cloned from. You can use the command to modify the name of the folder that Git generates.

git clone URL new-name

This command has now initialised the git repository in the project directory. We don't need to do "git init" once more.


Git Status

git status

To check the status of the repository we are in, run this command. Let's examine the results of running this command on the project that we previously cloned. Keep in mind that you must cd into that directory first.

I'll describe every line in the output.
  • Git is on the master branch, as indicated by the statement "on branch master" (which is the default branch). In a subsequent section of this article, I shall discuss branches.
  • A Git clone was used to copy this repository from another computer, therefore this is telling us that it is current with the one we cloned from. b) Your branch is up-to-date with 'origin/master
  • No pending modifications that need to be committed to the local repository are indicated by the message "Nothing to commit, working directory clean."






 

How is the version control system Git used?

The version control tool used by developers worldwide is called Git. It enables you to communicate with other developers and keep track of various code versions. You may wish to keep track of what modifications were made, by whom, and when you are working on a project over time.

Is Git a version management programme?

Git is an open-source distributed version control system that supports software teams in the productive, quick, and asynchronous development of projects of all sizes.

Why is Git the top version management tool?

For version control, a lot of people favour Git for the following reasons: Committing is quicker. In SVN, network traffic increases due to more frequent commits to the central repository. While using Git, you primarily work on your private repository and occasionally contribute to the main repository.

Free Demo Classes

Register here for Free Demo Classes

Trending Courses

Master Certification in Digital Marketing  Programme (Batch-11)
Master Certification in Digital Marketing Programme (Batch-11)

Now at just ₹ 64999 ₹ 12500048% off

Professional Certification Programme in Digital Marketing (Batch-4)
Professional Certification Programme in Digital Marketing (Batch-4)

Now at just ₹ 49999 ₹ 12500060% off

Advanced Certification in Digital Marketing Online Programme (Batch-21)
Advanced Certification in Digital Marketing Online Programme (Batch-21)

Now at just ₹ 24999 ₹ 4999950% off

Advance Certification In Graphic Design  Programme  (Batch-8) : 100 Hours Live Interactive Classes
Advance Certification In Graphic Design Programme (Batch-8) : 100 Hours Live Interactive Classes

Now at just ₹ 15999 ₹ 2999947% off

Flipkart Hot Selling Course in 2024
Flipkart Hot Selling Course in 2024

Now at just ₹ 10000 ₹ 3000067% off

Advanced Certification in Digital Marketing Classroom Programme (Batch-3)
Advanced Certification in Digital Marketing Classroom Programme (Batch-3)

Now at just ₹ 29999 ₹ 9999970% off

Basic Digital Marketing Course (Batch-24): 50 Hours Live+ Recorded Classes!
Basic Digital Marketing Course (Batch-24): 50 Hours Live+ Recorded Classes!

Now at just ₹ 1499 ₹ 999985% off

WhatsApp Business Marketing Course
WhatsApp Business Marketing Course

Now at just ₹ 599 ₹ 159963% off

Advance Excel Course
Advance Excel Course

Now at just ₹ 2499 ₹ 800069% off