What is a Git Repository

A git repository is the location where is stored the data related to your files, directories and git history for a Git Project.

In this beginner version control with Git tutorial, you will learn what a Git repository is.

Understand What a Git Repository Is

Git is program tracking changes that are made to files and directories.

Subscribe to my Newsletter

A Git repository is the .git folder inside a project that tracks all the changes that are made in your project

The history of changes is saved in the .git directory. Deleting that repository means that you are deleting the history.

You can create or edit any of the files or directories in a project directly. Git will store extra information about the project’s history. By combining the files and directories with the extra information stored by Git, you get a repository.

Creating a Git Repository with git Init

To create a Git repository, open the Terminal and use the git init command.

$ git init

What git init does is that it creates the git repository inside your project.

After using the git init command, you will see that the .git repository was created in your project (make sure that hidden files are showing Command + Shift + . ).

What the Git Repository Contains

A git repository contains the history of any file you may add, rename, update or remove from a project.

If no changes were staged yet, the git repository will contain 3 files and 4 directories.

  • config
  • description
  • HEAD
  • hooks/
  • info/
  • objects/
  • refs/

Git Config

The git configuration file is used to store the configuration of a git repository. The .git/config file contains variables that affect the behaviour of Git commands. Learn about git config on scm.

Git Description

The git description file is a text file used to describe what the git repository is about. The .git/description file should simply contain the name of the repository that you want to set.


The git HEAD file is a reference to the commit you are currently working on. The .git/HEAD file points to the head of the currently active branch (commit that you have checked out in your working directory).

Git Hooks

Git hooks are shell scripts used to automate the development lifecycle. Hooks use events to trigger actions. They are found in the hidden .git/hooks  directory of a Git repository.

Git Info

Git info shows information about a Git repository.


Git Objects

Git contains an object database (git objects) that stores objects as key/value pairs. Git objects are found in the .git/objects hidden subdirectory. They are used to insert any kind of content into a Git repository and retrieve that content using the unique key handed by Git.

Git Refs

A Git reference is are easy-to-remember names that reference a Git commit ID (e.g. The Git Branch master). Git references make it easier to refer to Git commits using names instead of hashes. Git refs are stored in the .git/refs hidden directory.

Other Version Control with Git and Github Posts

Learn Git and Github (Complete Guide)
Get Started With Github

How to Use Git and Github with VSCode

5/5 - (1 vote)