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 .gitYou will see entries such as:
HEAD: a small file pointing to the current branchconfig: settings for this specific repository
objects/: the database of all snapshots and contentrefs/: 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
BeginnerInitialize 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 branchconfig: repository-specific settingsobjects/: database of all snapshots and contentrefs/: pointers to branches and tags
ls .gitDeleting .git removes all history and makes the folder a plain directory again.
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Version Control
2Getting Started
Initialize A RepositoryThe .git FolderConfigure Your IdentityGit StatusRecap - First Repo8Merging
What Is A MergeFast-Forward MergeThree-Way MergeMerge ConflictsResolve A ConflictRecap - Merge Master11Feature Branch Project
Project OverviewInitialize Main3Tracking Changes
The Staging AreaGit AddGit CommitModifying A Tracked FileGit LogRecap - First Commits6Recipe Site Project
Project OverviewInitialize And Ignore