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
A repository gives your project memory.

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:

Project Directory
$

Initialize Git inside it:

Initialize Git
$

Git creates a hidden directory:

Terminal
$
The .git directory is the repository itself.

Configuring Git identity

Global configuration

Applies to all repositories on your machine.

Global Config
$

Local configuration

Applies only to the current repository.

Local Config
$
Local config overrides global config.

Repository workflow

A Git repository works with three areas.


Working directory

This is where files are edited.

Working Directory
$

Staging area

The staging area prepares changes for history.

Staging Changes
$
Staging lets you choose what becomes part of a commit.

Commit history

A commit records a snapshot of staged changes.

Commit
$

The .gitignore file

Some files should never be committed:

  • node_modules
  • environment files
  • logs
  • build outputs

Example:

node_modules/
.env
dist/
*.log

Ignored files are never tracked by Git.

Viewing commit history

Commit History
$
History explains how and why the project evolved.

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.