Learn computing fundamentals, programming, algorithms, systems, and software engineering.
Version control records changes to your files over time so you can revisit any earlier state of a project, understand what changed and why, and collaborate with others without overwriting each other. Git is the most widely used version control system, and unlike older tools it is decentralized: every clone of a repository contains the full history. Git organizes work into a repository (a folder whose history Git tracks). You make changes in your working directory, then stage the changes you want to keep (git add), and finally commit them (git commit) with a message describing the change. A commit is a permanent snapshot you can always return to. Branches let you work on a feature in isolation. The main branch holds the stable state, while a feature branch lets you experiment freely. When the feature is ready you merge the branch back, and Git combines the changes automatically. If two people edit the same lines, Git reports a conflict that must be resolved by hand. Remote repositories (on services like GitHub or GitLab) let you back up your work and collaborate. You push your commits to a remote, and pull other people commits down to your machine. A common beginner mistake is editing files and wondering why Git does not see the changes — nothing is tracked until it is staged and committed. Another is committing large, unrelated changes together, which makes history hard to read.
As a project grows it becomes impossible to remember every change or undo a mistake by hand. Version control records each change so you can always go back, see what changed and why, and work with others without overwriting their work.
| Git | GitHub | |
|---|---|---|
| What it is | Version-control software | A hosting service for Git repos |
| Where it runs | On your own machine | In the cloud |
| Purpose | Track changes | Share and collaborate |
| Analogy | The engine | The garage where cars are kept |
Understanding the four areas explains almost everything Git does. Changes move forward through them one step at a time.
The -m flag supplies the commit message inline. Without it Git opens a text editor for you to write the message.
Make a change, stage it, and commit it. This is the cycle you repeat dozens of times a day.
On branch main Changes to be committed: new file: app.py [main 9f3c1ab] Create app.py 1 file changed, 1 insertion(+)
Work on a branch, then bring it back into main with a merge.
Switched to a new branch 'feature/greeting' Updating main..feature/greeting Fast-forward app.py | 1 + 1 file changed, 1 insertion(+)
git log shows every commit, newest first, with its author and message.
9f3c1ab Create app.py 2b1e0aa Initial commit