Creating Repositories
A Git repository is a directory containing:
- Your project files and folders
- A
.git/folder with version history and configuration
What Is a Git Repo?
Git repo = Project folder + Git storage
💡 Do not modify anything inside .git/
Why Make a Git Repo?
| Reason | Benefit |
|---|---|
| 📌 Version tracking | Store historical versions of your project |
| 🧪 Experimentation | Revert if something breaks |
| 🧑🤝🧑 Collaboration | Work with others easily |
Create a New Git Repo
git init mental-health-workspace
cd mental-health-workspaceNow check the status:
git statusExpected:
On branch main
No commits yet
nothing to commit (create/copy files and use "git add" to track)Convert Existing Folder to Git Repo
cd existing-folder
git initExpected Output:
Initialized empty Git repository in /path/to/folder/.git/What Is Being Tracked?
git statusExample Output:
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
data/
report.md
nothing added to commit but untracked files present (use "git add" to track)Nested Repositories ⚠️
🚫 Never place a Git repo inside another Git repo
Why?
- Two
.git/directories confuse Git - Git won’t know which repository to update
Try It Yourself
Problem 1: Create a Repository
Show Code
mkdir my-project
cd my-project
git initProblem 2: Inspect an Existing Folder
Show Code
cd /path/to/folder
git status