Git: What it is and How it Works

Git is a very popular, powerful, and efficient open-source Version Control System that tracks content like files and directories. Its main purpose is to manage a project or set of files as they change over time.

Of course, that was the short version of Git. Let’s dig in a little more and talk about this particular Version Control System and see how it works, and what you can use it for.

What is Git?

Git is a Version Control System or VCS as it is more commonly referred to, that tracks the history of changes when people and teams collaborate on projects together. As a project evolves, teams have the ability to run tests, fix bugs, and contribute new code with the confidence that any version can be recovered at any time.

There are actually several really popular Version Control Systems out there. Some of these include CVS, SVN, Mercurial, Fossil, and, of course, the one we are focusing on in this article, Git.

It actually serves as a foundation for other services like GitHub and GitLab. That being said, you can use Git without using the other services, which means you can use it privately.

Developers and other teams members can review project history to find out things like:

  • Which changes were made?
  • Who made the changes?
  • When were the changes made?
  • Why were the changes needed?

Git is an example of a distributed version control system (DVCS), which is most commonly used for open source and commercial software development. A DVCS allows full access to every file, branch, and iteration of a project. It also allows every user access to a full and self-contained history of all changes.

Git does not need a constant connection to a central repository. Developers are able to work and collaborate from anywhere and any time zone.

How it Works

Git stores file content in something called binary large objects, or BLOBs. These folders are represented as trees, with each tree containing other trees (also called subfolders) and other BLOBs, along with a simple text file that has the mode, type, name, and SHA (Secure Hash Algorithm) of each BLOB and subfolder entry.

When a repository transfer occurs, even if there are multiple files with the same content and different names, Git software will transfer BLOB once and then expand it to all the different files.

The complete history of your project is stored in what is called a commit object. Whenever you make a modification to your project you have to commit it. Each commit file keeps the author, committer, commit, and any parent commits that have directly preceded it.

There are different ways to use Git, depending on the type of system you are running. After it is installed you can work with it how you prefer. You can basically install it on MAC OS and Linux, or install it on Windows. Choose the version and installation method you need and you will be ready to move forward from there.

When You Should Use GIT

We touched on this a little above, but let’s expand a little on it. Git is basically designed to manage source code. In most languages, this consists of lines of text. This VCS doesn’t care what the text is that it is managing.

It could be a personal project, or a massive scale project, all it wants to do is help you manage and track versions so that you can see updates and changes along the way.

Now, be aware that Git can definitely manage other format file types. However, it treats them as BLOBs, which we talked about above.

The issue is that if you have two photos that have different text or source code changes on them, Git will not be able to see the difference. This is because the photos are not made of any type of text that can be configured or removed from the commit.

If you can learn the system, then it really is for everyone. It is a fantastic way to manage versions of your files and is a very powerful tool. It seems like a complicated system, but like anything else, if you learn it, it isn’t as scary as it appears.

Basic Git Commands

In order to use Git, developers have to learn specific commands to copy, create, combine, and change code. These commands can be executed directly from the command line. Again, this is another area of the system that you need to learn. And we actually have a number of Git tutorials for you to use to learn the entire process of using it.

Some of the basic Git commands include:

  • init
  • clone
  • add
  • commit
  • status
  • branch
  • merge
  • pull
  • push

Note: each command starts with the word “git.” For example, the command for “init” would actually be “git init.”

These are just some of the basic commands available. You can learn more, including the top 20 Git commands as well.

What is a Repository?

A repository, or project, is a complete collection of all files and folders associated with a project along with each file’s revision history. The file history appears as timeline snapshots that are called “commits.”

These commits exist as a linked-list relationship, and they can be organized into multiple lines of development. These separate development lines are known as “branches.” There is a lot to learn about repositories. You can learn to create them, manage them, and inspect them.

You will also be able to navigate them better if you learn repository structure and how it works.

Advantage of Git

The biggest advantage of Git lies in its branching capabilities. Unlike centralized Version Control Systems, Git branches (trees, subfolders) are cheap and very easy to merge.

Because of this, it facilitates the feature branch workflow that is so popular with many Git users. Feature branches provide an isolated environment for every change to your codebase.

Difference Between Git and GitHub

As mentioned above, Git is an open-source Version Control System for managing and tracking projects. It is basically a tool that manages your source code history.

GitHub is the hosting service for all Git repositories. Simply put, Git is the tool, but GitHub is the service for the projects that use it.

Does Git Stand For Anything?

The inventor of Git, Linus Torvalds, has readily admitted that Git can mean anything, depending on your mood. It is a random three-letter combination that is pronounceable, and not actually used by any common UNIX command.

The fact that it is indeed a mispronunciation of the word “get” may or may not be relevant.

Final Thoughts

There you go, a quick and simple rundown of Git and what it does. At first glance, the system is going to seem very complicated. Honestly, it will take a little time to learn. However, this is the case for anything new.

That being said, if you have a willingness to learn it, and it is something you will use in the future, then learning how to use Git may be one of the smarter things you do. It has a ton of tools and is an excellent program for tracking revisions and sharing across multiple users who are all working on the same project.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.