The Git Dungeon: Version Control for Solo Adventurers
## Welcome to the Git Dungeon
Every adventurer needs to track their progress through the dungeon. In the world of software development, **Git** is your quest log — it records every change, every victory, and every mistake so you can always find your way back.
### What is Git?
Git is a **distributed version control system**. Think of it as a magical tome that records the history of your project. You can:
- Save checkpoints (commits) at any point in your journey
- Branch off into parallel timelines (branches) to experiment safely
- Merge your experiments back into the main timeline
- Travel back in time to any previous checkpoint
### Your First Steps
Every Git repository starts with a single command run in your project folder:
```bash
git init
```
This creates a hidden `.git` directory that contains all of Git's tracking data. Congratulations — your project is now a Git repository.
### The Sacred Workflow
The fundamental Git workflow has three stages, much like a blacksmith forging a blade:
1. **Working Directory** — Where you make changes (edit files, create new ones)
2. **Staging Area** — Where you prepare changes for a commit (like gathering ingredients)
3. **Repository** — Where commits are permanently stored (the finished sword)
Here's the cycle:
```bash
# 1. Make changes to your files
echo "print('Hello, Dungeon!')" > main.py
# 2. Stage the changes
git add main.py
# 3. Commit the changes with a message
git commit -m "Add the first spell to my grimoire"
```
### Why .gitignore Matters
Not everything belongs in your quest log. Generated files, dependencies, and secrets should stay out. The `.gitignore` file controls this:
```gitignore
# Ignore Python bytecode
__pycache__/
*.pyc
# Ignore dependencies
node_modules/
# Ignore environment secrets
.env
```
### Key Takeaways
- `git init` begins your repository journey
- The cycle is: **edit → add → commit**
- `.gitignore` keeps your log clean
- Git lets you experiment fearlessly — you can always return to a previous checkpoint
Now that you understand the basics, prepare for your first trial. Answer the quiz below to prove your knowledge and unlock the next chamber.