CodeBlanks Logo Icon CodeBlanks

The .git folder

Learn the internal structure of the .git folder.

What Is the .git Directory?

The .git directory in a Git repository's root stores the internal data required for version control. Commit history, branches, tags, configuration, and the object database are associated with this directory. If it is deleted, working files may remain, but the repository's Git history and management data are lost.

project/
├── .git/
├── index.html
└── style.css

Because it is hidden, some file managers require hidden files to be displayed.

Important Parts of the .git Directory

objects stores Git objects, while refs stores branch and tag references. The HEAD file usually points to the current branch; config contains repository settings. The index stores information about files prepared for the next commit.

.git/
├── HEAD
├── config
├── index
├── objects/
└── refs/

These components work together to let Git manage repository state and history.

Practice Inspect the .git Structure

Complete the terminal command to list the repository's internal structure. Include hidden directories and display only the contents of the .git directory.

Starter code

terminal
# .git içeriğini gizli öğelerle birlikte listele

Expected output

HEAD config index objects refs

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Where are a Git repository's commit history and internal version control data primarily stored?

  • In the .git directory Correct answer
  • In the README file in the working directory
  • Only on the remote server
  • At the end of every source file

Explanation: The .git directory contains the repository's internal Git data and history.

2 Find the Internal Configuration File

Question
.git/
├── HEAD
├── config
├── index
└── objects/____
Answer
.git/
├── HEAD
├── config
├── index
└── objects/config

Explanation: <code>config</code> is the file that stores repository-level Git settings.

3 Components of the .git Directory

Term Meaning
HEAD Points to the current position or branch
config Stores repository settings
index Stores the staged file state
objects Stores Git objects

All lessons in Expert