Git is a version control system (VCS). Its main job is to keep track of how files—especially source code—change over time. You can think of Git as a history system designed for software projects. It knows not only what your project looks like now, but also what it looked like before, who changed it, what was changed, and when those changes happened.
Without Git, a beginner might try to keep different versions of a project by copying the entire folder every time something important changes. After a while, the project may look something like this:
my-project
my-project-v2
my-project-final
my-project-final-new
my-project-final-really-finalThis can work for a very small project, but it quickly becomes confusing. It becomes difficult to tell which folder is the latest version and what exactly changed between two copies. Git solves this problem by allowing you to keep one working copy of the project while Git records its history for you.
In Git, a saved point in your project's history is called a commit. For now, you can think of a commit as a snapshot of your project after a meaningful change. For example, if you create a website, add a login page, and then fix a login bug, your Git history might look like this:
Commit 1: Create the project
Commit 2: Add the login page
Commit 3: Fix the login problemThis history becomes very useful when something goes wrong. Instead of relying on memory, you can look back and see which files were changed, what lines were added or removed, and when a particular change was introduced.
Git is also extremely useful when several developers work on the same project. For example, one developer might work on login, another on the user profile, and another on payments. Git allows them to work on separate branches and combine their work later. This reduces the chance of everyone interfering with the same code at the same time. Branches are covered later in the course.
What Is the Difference Between Git and GitHub?
Git and GitHub are often mentioned together, which makes them easy to confuse. They are not the same thing. Git is the version control tool that runs on your computer, while GitHub is an online platform for hosting Git projects and collaborating with other developers.
A simple way to picture the relationship is:
Your computer
Git: manages your code history
GitHub: hosts Git projects online
You can use Git without GitHub. For example, you can create commits, inspect your project history, and work with branches entirely on your own computer. GitHub adds online storage and collaboration features such as Pull Requests, Issues, code review, and CI/CD. We will cover those features later in the tutorial.
For now, the key idea is simple: Git is the version control tool, while GitHub is an online platform built around Git repositories.
KNOWLEDGE QUIZ
Practice
Your classmate saves an assignment as project-final, project-final-new, and project-really-final. Identify two specific problems with this approach and explain how Git improves each one.