What Are Version Control & Git?
Key points
- Version control is a system that records who changed what, and when, so you can always return to an earlier state if you need to.
- Git is the leading tool for this. It records changes as units called "commits" and stacks them up into a history.
- Combined with a service like GitHub, it becomes much easier for multiple people to develop in parallel and review each other's code.
into history
to the past
Teacher Pochi works with a team like this every day, too
What happens without version control
Teams that don't use version control tend to manage files by copying them and naming them things like "report_final.docx", "report_final2.docx", and "report_final2_revised.docx". Nobody can tell which one is the latest, and if two people edit at the same time, whoever saves last can overwrite the other person's work.
Teacher Pochi's hintImagine several people sharing one notebook, passing it around to write in — except someone keeps erasing a previous page and rewriting it. Soon nobody can tell who wrote what, or what the original said.
What is version control?
Version control is a system that automatically records a file's change history, so you can track "when, who, what, and why" something was changed. Because the history is preserved, when something goes wrong you can pinpoint the change that caused it, or roll back to an earlier state.
It's similar to the "track changes" feature in Word or Excel — but it helps to picture that idea extended beyond a single file, to an entire project and an entire team.
Teacher Pochi's hintIt's a lot like a "save point" in a video game. If you save often, a failed attempt just means restarting from the last save instead of losing everything.
What is Git?
Git is by far the most widely used version control system today. Its defining feature is that it's "distributed": the complete history isn't just kept on a central server — every team member's own computer holds a full copy of it too.
That means you can keep working and reviewing history even without a network connection, then sync your local changes to the team's shared location later.
Repositories and commits
In Git, the container that stores the history is called a "repository," and a single recorded change is called a "commit." A commit is like a snapshot of your files at that moment in time — with each commit, the history builds up further.
Initial version
Add feature
Fix bug (latest)
Teacher Pochi's hintThink of putting together a travel photo album, snapping a picture at each notable moment. Looking back at those photos (commits) later lets you retrace when, where, and what happened.
Working directory, staging area, and repository
Changes in Git aren't recorded into the history the instant you make them. They pass through three stages: the "working directory" (where you're currently editing), the "staging area" (where you choose what to include in the next commit), and the "repository" (where changes become permanent history).
directory
area
(history)
This setup lets you choose to record "just this part" of what you edited. We'll cover this in more detail in "Git Basics."
The idea of a branch
A branch lets you split off from the main line of history and make changes without affecting anyone else's work. Once your work is done, you "merge" the branch back into the main line, combining everything into a single history.
(main line)
branch
(after merge)
Teacher Pochi's hintIt's similar to a "choose your own adventure" branching storyline. You try out a different route from the main story, and if it turns out well, you fold it back into the main story. We'll cover this in more detail in "Branching Strategy."
Collaborating on GitHub
GitHub is a service that lets you share a Git repository over the internet. A common workflow is for each team member to propose their changes as a "pull request" against the shared repository, which other members then review before it's merged into the main line.
pull request
We'll cover this in more detail in "Collaboration on GitHub."
Summary
Version control and Git are the foundational knowledge for recording change history and developing safely as a team. Remember the flow: commits build up the history, branches let work split off, and services like GitHub share it all with the whole team.
You can dig deeper into each of these ideas in the individual topics below.
Related topics: