CodeBlanks Logo Icon CodeBlanks

The .git folder

Learn what the .git folder stores in a repository.

Inside the .git folder

The .git folder is the brain of the repository; everything Git uses to keep history stays here. You mostly care about objects, refs and config. objects stores file contents, refs holds named pointers, and config keeps the repository settings.

ls .git
HEAD
config
description
hooks
info
objects
refs

The config file

The config file keeps settings that belong to this repository. For example, the name and e-mail shown in your records are written here. Even when objects and refs are empty, the config file is there from the start.

cat .git/config
[user]
    name = Ayse
    email = ayse@example.com

Practice List the repository structure

Start a repository in the current folder in quiet mode. Then list the inside of the .git folder so the repository structure appears on screen.

Starter code

terminal
# 1) bu klasorunde depoyu sessizce baslat
# 2) .git klasorunun icini listele

Sample solution

terminal
git init -q
ls .git

Expected output

HEAD
config
description
hooks
info
objects
refs

Questions and answers

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

1 Which file inside the .git folder holds the repository settings?

  • Inside the HEAD file
  • The config file Correct answer
  • A record in the objects folder
  • A pointer in the refs folder

Explanation: Settings live in the config file; objects holds file contents, refs holds pointers, and HEAD points at the current spot.

2 Show the settings

Question
cat .git/____
Answer
cat .git/config

Explanation: The repository settings live in the config file inside the .git folder.

3 .git parts

Term Meaning
objects Stores file contents
refs Holds named pointers
config Holds repository settings
HEAD Shows the current spot

All lessons in Beginner