Skip to content

Latest commit

 

History

History
159 lines (95 loc) · 3.25 KB

File metadata and controls

159 lines (95 loc) · 3.25 KB

🏁 git init (Start a Repository)


🎯 What It Does

Initializes a Git repository.


🧪 Command

git init

📁 What Happens?

A hidden folder is created:

.git/

👉 This is the heart of Git


📸 Visual (.git Structure)

Image

Image

Image

Image

Image

Image

Image


🏗 Inside .git/ Folder

.git/
├── HEAD
├── config
├── description
├── hooks/
├── info/
├── objects/
└── refs/

🔬 Important Files Explained

1. HEAD

ref: refs/heads/main

👉 Points to current branch


2. config

[core]
    repositoryformatversion = 0

👉 Stores repo-specific settings


3. objects/

👉 Stores all Git data:

  • blobs (files)
  • trees (folders)
  • commits

4. refs/

Stores pointers:

refs/
 └── heads/
      └── main

👉 Branch references


5. hooks/

  • scripts triggered by Git actions
  • example: pre-commit hook

6. info/

  • additional repo info
  • rarely used by beginners

🔥 Key Insight

Git repository = .git/ folder

If .git/ is deleted → history is gone.


🧠 What Has NOT Happened Yet

After git init:

  • ❌ no commits
  • ❌ no tracked files
  • ❌ empty repo

🧠 Memory Trick

git init = create Git brain (.git)


⚠️ Common Mistakes

  • running inside wrong folder
  • nesting repositories
  • deleting .git accidentally

➡️ Next Step

👉 07-git-status.md