Version control is a system that tracks changes to files over time. Think of it like a "time machine" for your code that allows you to:
- See what changed in your files and when
- Go back to previous versions if something breaks
- Work with others without overwriting each other's work
- Keep a complete history of your project's development
Imagine you're writing a research paper:
Without Version Control:
essay.docxessay_final.docxessay_final_v2.docxessay_final_v2_really_final.docxessay_final_v2_really_final_FOR_REAL.docx
Sound familiar? This gets messy quickly!
With Version Control:
- One file:
essay.docx - Complete history of all changes
- Ability to see exactly what changed between versions
- Easy rollback if you mess something up
- Never lose your work again
- Recover deleted files
- Restore previous versions
- See what changed, when, and who made the change
- Understand the evolution of your project
- Multiple people can work on the same project
- Merge changes automatically
- Resolve conflicts when people edit the same code
- Work on features separately
- Experiment without breaking the main code
- Switch between different versions easily
- Commit messages explain why changes were made
- Link changes to bug reports or feature requests
- Git (most popular, what we'll learn)
- Subversion (SVN)
- Mercurial
- Bazaar
Git is special because it's:
- Distributed: Every copy of the code contains the full history
- Fast: Operations happen locally
- Flexible: Supports many different workflows
- Popular: Used by most open-source projects and companies
- Repository (Repo): A folder that contains your project and its history
- Commit: A snapshot of your project at a specific point in time
- Branch: A parallel version of your project
- Merge: Combining changes from different branches
- Remote: A version of your repository stored elsewhere (like GitHub)
In the next tutorial, we'll dive deeper into why Git specifically has become the standard for version control.
Continue to Part 2: Why Use Git?
Before moving on, think about these questions:
- Can you think of a time when version control would have saved you from losing work?
- What challenges do you face when working on group projects?
- How do you currently keep track of different versions of your files?
Write your answers in a text file and save it. We'll use this file in later exercises!