Initializes a Git repository.
git initA hidden folder is created:
.git/
👉 This is the heart of Git
.git/
├── HEAD
├── config
├── description
├── hooks/
├── info/
├── objects/
└── refs/
ref: refs/heads/main
👉 Points to current branch
[core]
repositoryformatversion = 0👉 Stores repo-specific settings
👉 Stores all Git data:
- blobs (files)
- trees (folders)
- commits
Stores pointers:
refs/
└── heads/
└── main
👉 Branch references
- scripts triggered by Git actions
- example: pre-commit hook
- additional repo info
- rarely used by beginners
Git repository =
.git/folder
If .git/ is deleted → history is gone.
After git init:
- ❌ no commits
- ❌ no tracked files
- ❌ empty repo
git init = create Git brain (.git)
- running inside wrong folder
- nesting repositories
- deleting
.gitaccidentally
👉 07-git-status.md