Repository
Repository
▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲
▼▲▼▲▼▲▼
tags : #git
references : version control
▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲▼▲
▼▲▼▲▼▲▼
🧱 WHAT IS A REPOSITORY?
A repository (repo) is a container for:
Think of it as a digital brain that remembers everything your project has gone through.
🧠 TYPES OF REPOSITORIES
1. Local Repository
Lives on your own machine.
Where you make commits, branches, etc.
Always created with:
git init
2. Remote Repository
Hosted on a platform (GitHub, GitLab, Bitbucket, Gitea, self-hosted).
Used for collaboration and backup.
Linked via URL:
Folder/File Purpose
HEAD Points to the current branch
config Your Git repo settings
refs/ Contains branches and tags
objects/ All commits, blobs (file data), trees (directory structures)
index The staging area
hooks/ Automation scripts you can run pre/post actions
logs/ History of actions like switching branches
You can break your repo completely by messing with this. But mastering it gives you elite
control.
Every object has a SHA-1 hash ID. That’s how Git stays secure and traceable.
🔗 CLONING A REPOSITORY
You don’t just get files — you get the entire history too:
git clone https://github.com/user/project.git
every commit
all branches
config and remotes set
🏭 Bare repo
Contains only the .git data (no working files).
Used as central servers/remotes.
Cannot be used to write code directly.
🧨 COMMON PITFALLS
Deleting .git = repo is dead. Always have a remote backup.
Committing secrets (API keys) = security risk. Use .gitignore .
Not using branches = risky changes in production.
Confusing origin with upstream when forking.
📌 TL;DR Summary
A repository is your project's brain — with full memory, history, and structure.
It can be local or remote, bare or non-bare.
Every repo has internal structure: objects, trees, commits, branches.
Tools like GitHub/GitLab manage remote repos and team collaboration.
Understanding a repo’s internals = mastering your project’s soul.