Menu
Coddy logo textTech

The .git Folder

Part of the Version Control section of Coddy's Terminal journey — lesson 5 of 58.

The .git folder is where Git stores everything: every commit, every branch, your configuration, and pointers to the current state of the repo.

You almost never edit anything inside .git directly. Git commands modify it for you. But it is useful to know what is in there:

ls .git

You will see entries such as:

  • HEAD: a small file pointing to the current branch
  • config: settings for this specific repository
  • objects/: the database of all snapshots and content
  • refs/: pointers to branches and tags

If you ever delete the .git folder, the project stops being a Git repository. The files themselves stay, but the entire history is gone.

challenge icon

Challenge

Beginner

Initialize a new repository in the current folder, then check whether the file HEAD exists inside the .git folder.

Use cat .git/HEAD to print its contents. The expected output is the branch pointer line.

Cheat sheet

The .git folder stores everything Git needs. Key contents:

  • HEAD: points to the current branch
  • config: repository-specific settings
  • objects/: database of all snapshots and content
  • refs/: pointers to branches and tags
ls .git

Deleting .git removes all history and makes the folder a plain directory again.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Version Control