Understanding Git terminology

Share this article

To understand Git, you have to understand the terminology. Here’s a shortlist of terms that Git users frequently use.

Picture from https://en.wikipedia.org/wiki/Git#/media/File:Git_operations.svg

The above picture shows you a bigger picture of how git works and the context of the terminology.

Repository

A git repository is a directory, a place for your codebase and it also keeps all the history and metadata for a project. which means the repository tracks all changes made to files and directories in your project.

Git repository is classified into two types on the basis of user permissions:

Bare Repositories


A bare repository is used for sharing or backup, single users are not allowed to create the new version of the repository. A bare repo is usually a directory with a name that ends in .git—for example, project .git. It doesn’t have any working directory in them.
The below snapshot shows the content of the .git directory.

Non-Bare Repositories

The major difference between bare repo and Non-bare repo is that bare repo has a working directory inside it. When you clone the repository it creates a non-bare repository. Users can modify the existing repository and create new versions.

Working tree

The working tree in git is a place where you actually work on files and subdirectories.

Object

An object is a special kind of variable that has distinct characteristics and behaviors. Git has 4 objects — blob, tree, commit and tag

blob object

Binary large object (blob) is the content of a file. A blob’s name internally is a hash of its content. In git each blob is a version of a file, it holds the file’s data.

Tree object

A tree object is the equivalent of a directory. It is used to store a group of files together and it also solves the problems of storing the filename. The file system stored in GIT is similar to the UNIX filesystem. All the content in git is stored as tree and blob objects, where blobs corresponding inodes or file contents and trees corresponding to UNIX directory entries.

commit object

A commit object links tree objects together into history. It contains the directory tree object hash, parent commits hash, commit message, author, and date.

Tag object

A tag object is a container that contains a reference to another object and can hold added meta-data related to another object.

Commit

Commit means to make a commit object. commits are snapshots of your entire repository at specific times. It means you are committing the changes you have made so that others can eventually see them. It is like a story when users see the old commit they will understand how you reached this point.

Branch

This is one of the most important concepts, It allows you to branch the project into a separate copy so that you can experiment, develop features or do bug fixing. To be worked on at the same time, possibly by different people in isolation of the main codebase. Once a branch is completed and well-tested and reviewed, it can then be merged back into the main branch and it becomes part of the project

Head

It is the most recent commit on a working branch.

Tags

It is a branch reference but fixed to a particular commit. Used to label important points in history.

Remote

As the name suggests that Remote Repository in Git is a special type of repository which is hosted remotely. It doesn’t have a working Tree. Basically, remote repos are central repositories where you can push your changes into ( other people can see them) or pull from (so that you can get others’ changes).

Leave a Comment

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