Quick explaination of how git works

Almost every developers uses git for their day to day task, but not every one knows about how it actually works.

If you initialize a git repository using the following command

git init         

Or when you clone from a repository there will be a file with the name of .git

Inside it there are several files and folders

Article content

The HEAD file:

one of the most important file is HEAD. If you open it, you'll see something like this:

ref: refs/heads/main        

which points to refs/heads/main file inside the .git folder

The refs folder:

Inside the refs folder there are files for all of the branches in repository.

In this case if you open refs/heads/main, you'll see a commit hash similar to this:

0e5bebf911df44080b0e5617e348436c0997e017        

This is the hash of the commit That is used for tracking changes by git.

The objects folder:

The latest versions of the actual files in the repository will be stored as blob inside the object folder

The logs folder:

The reference of everything that happenes in repository will be stored in logs folder, which allows git to maintain history of events.

The hooks folder:

The hooks folder contains the custom scripts that can be executed at different stages of git workflow, such as "pre-commit", "pre-push" and other hooks which used for automating task like linting before push

Ali Naghiee

Software Engineer At HasinGroup ❲Maani❳

7mo

👏👏👏

Nima Tajik

Back-End Developer at HasinGroup(Maani)

8mo

😍👏🏼👌🏼

To view or add a comment, sign in

More articles by Soheil Pasbakhsh

  • Loops in bash

    There are mostly two types of loops in Bash/Linux, for loop and while loop While loop has a condition that as long as…

  • Quick fix for EADDRINUSE error in linux

    You might get EADDRINUSE error in some situations which means a port in the system that you want to use is being used…

Insights from the community

Others also viewed

Explore topics