13. Version Control & Collaboration
Never lose your work again
Version control is a system that records every change made to your code over time. It's like having infinite undo history for your entire project, combined with the ability to work in parallel with a team without overwriting each other's work.
Without version control, developers used to email zip files to each other labeled "final_v3_ACTUALLY_FINAL.zip". This was painful, error-prone, and didn't scale. Version control solved this entirely.
Introduction to Git
Git is the most widely used version control system in the world. Created by Linus Torvalds (the creator of Linux) in 2005, it's now the industry standard. GitHub is a website that hosts Git repositories online and adds collaboration features.
Repositories & Commits
A repository (repo) is a folder where Git tracks changes. A commit is a snapshot of your project at a specific point in time β like saving a checkpoint in a game:
A good commit message explains WHY you made the change, not just what. 'Fix bug' is useless. 'Fix login crash when email has uppercase letters' is valuable. Your future self will thank you.
Branching Basics
Branches let you work on new features or bug fixes without affecting the main codebase. When you're done, you merge your branch back:
Working in Teams β GitHub Workflow
The standard team workflow: (1) Pull latest changes, (2) Create a feature branch, (3) Make your commits, (4) Push to GitHub, (5) Open a Pull Request for review, (6) Merge after approval. This keeps the main branch always stable and production-ready.
Knowledge Check
Ready to test your understanding of 13. Version Control & Collaboration?