Git Elements – Post 1

In the last tutorial, I have discussed about the Workflow of GIT. in this post i will be discussing various terminologies associated with GIT. Since there are lot’s of terms that are used in GIT, so it won’t be possible to cover all of these terms in one post. Therefore, i will cover only five terms today, basically these are the Git elements or objects and update a new post on 3rd March, 2018. So Let’s just start

BLOB(Binary large object):

BLOB is nothing just a representation of data, in the binary form. Basically all multimedia objects are represented as BLOB objects. A blob holds the file data but doesn’t contain any meta-data (like size of the file, properties of the files (for eg. accessibility rights) about the file. In Git database every version of your repository is stored as BLOB object, and it is named as SHA1 Hash of:

  • Data in the file, &
  • The Header: Header Contains the information

 Therefore In Git, files are not addressed by names. Everything is content-addressed.

Reason: Why BLOB is used as basic representation of data?

Whenever you perform Git operation like git pull or push. That operation is performed instantly in few seconds. No matter whatever be the size of your files that you are retrieving or accessing through remote server. This is due to the BLOB. Whatever be the files or versions stored on Githyb server are first compressed through Zlib compression algorithm and converted to BLOB objects by GIT then transferred to the server using push Command.

As i said the operations of git are performed at quick speed due to BLOB object, But why?

One might think. If you are students from the computer science you might have been told in the beginning of the session that whatever be the digital data, it is represented as binary data. Therefore, to transfer data to the server, there is no need to convert that data into bits as it is already in its binary format, and data transfer takes at very quick speed, as oppose to other representation of data.

Tree

As you know, Git is a Version Control Tool. Each version should have a proper relationship with each other. Though there are lot’s of data structure like Array, link List, but tree is most suitable data ( reason can be understand by a post that i shared at end ) structure that can be used, for such type of functionality that Git provide.

In Git, Tree is an object, which represents a directory. It holds blobs as well as other sub-directories. A tree is a binary file that stores references to blobs and trees which are also named as SHA1 hash of the tree object.

Git Elements - Post 1 1
Tree Representation , Commits and Branches

Commits

In the last post i have told you about three working area that git have. There i also told you that whenever you want to finalize that changes you have to done to your workspace you need to commit those changes. That git commit operation, create a commit object. Commit holds the current state of the repository.

A commit is also named by SHA1 hash. You can consider a commit object nodes of tree object, where root node is the first commit that you made. Every commit object has a pointer to the parent commit object. If a commit has multiple parent commits, then that particular commit has been created by merging two branches.

Branches

While working in certain projects, you might be thinking of the certain features that might works with the current state of your project but don’t want to disturb the current state of repository. If we don’t have any version control Tool, then the simple thing that we do is create another directory in your system. Copy the contents of our project in that directory, and do changes in that directory. But that create unnecessary redundant data. Thanks to Git, it provides us a solution to do that changes in the same directory with the help of branching feature.

Branches are used to create another line of development within the same directory. Initially, Git has a master branch. Whenever you want to test some features, for which you are not sure about that what will be the consequences of the changes that you are going to do. You create a separate branch. When whole works regarding that updates is completed, it is merged back with the master branch and we delete the branch. Every branch is referenced by the first commit(HEAD) of that branch, as in the picture the blue line shown is a separate branch and can be referenced by 6c6faa5 commit hash. Whenever you make a commit, HEAD is updated with the latest commit.

Tags

Tag assigns a meaningful name with a specific version in the repository. Tags are very similar to branches, but the difference is that tags are immutable(i.e. can’t be changed, when tags are created). Once a tag is created for a particular commit, even if you create a new commit, it will not be updated. Usually, developers create tags for product releases.

Some additional Links that you should refer,

That’s it for today. Thanks for visiting if You have any doubt. You may Comment below, or can post question in Git discussion Forum

Content Protection by DMCA.com
Gaurav Raheja
Gaurav Raheja
Articles: 27

Leave a Reply

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