Repository
Let’s talk about what a Git repository really is, and how to work with it properly.
What is a Git repository?
A Git repository (often called a repo) is the core container of a project.
It stores:
- Source code
- Documentation
- The full history of changes
Without a repository, files are just files.
With a repository, every change is tracked, reversible, and explainable.
Creating a repository
Start with a simple folder:
Initialize Git inside it:
Git creates a hidden directory:
Configuring Git identity
Global configuration
Applies to all repositories on your machine.
Local configuration
Applies only to the current repository.
Repository workflow
A Git repository works with three areas.
Working directory
This is where files are edited.
Staging area
The staging area prepares changes for history.
Commit history
A commit records a snapshot of staged changes.
The .gitignore file
Some files should never be committed:
- node_modules
- environment files
- logs
- build outputs
Example:
node_modules/
.env
dist/
*.log
Viewing commit history
Visualizing history
Text logs are powerful, but visuals help.
IDE tools
- Git Graph (VS Code)
- GitLens (VS Code)
- Built-in IDE Git views
Libraries
- gitgraph.js
- gitgraph.ts
These tools turn commit history into clear diagrams.
Final thought
A Git repository is:
- A safety net
- A shared memory
- A collaboration engine
Once you understand the repository, Git becomes predictable and calm instead of confusing.