Tutelage

Lessons › coding and computer science · taught by Leo

Git version control basics: commits and staging

Learn how Git tracks project snapshots, why teams use version control, and how edit-stage-commit keeps history organized.

Learn this with Leo, freeA voiced lesson with a live whiteboard, quizzes and a tutor you can call, at tutelage.app

Why teams use version control

Imagine you are writing code and your file changes every day. Git helps you keep every version, so you can look back if something breaks.

It is like a time machine for your project. You can save snapshots instead of only keeping one messy final file.

That means teamwork gets easier too. Everyone can work without stepping on each other's changes.

Git saves snapshots

A commit is a snapshot of your project at one moment in time.

Git does not just store one file. It stores a history of saved snapshots called commits.

A commit is like a checkpoint in a game. You can return to it later if needed.

So version control means tracking changes safely over time.

Predict: what does Git track?

If you make a commit, what is Git really saving?

  1. Only the newest file
  2. A snapshot of your project
  3. A cloud backup of your laptop
Show answer

A snapshot of your project: Nice. A commit saves a snapshot of the project at that moment.

Commit history as snapshots

Here is the main idea. Each commit is one saved version, and Git links them into history.

When something goes wrong, you do not start over. You jump back to a good snapshot.

That is why Git feels so powerful for coding projects.

How commits connect

First you edit files. Those are your working files.

Then you stage the changes you want to save. Staging is like putting items in a cart before checkout.

After that, you make a commit. Git adds it to history.

That is the basic loop: edit, stage, commit, repeat.

working → stage → commit

Quick check: what comes next?

You changed a file and want to save that version in Git. What should you do next?

  1. Delete the file
  2. Stage the change, then commit it
  3. Rename the branch first
Show answer

Stage the change, then commit it: Yes. Stage first, then commit. That saves the change into history.

Why staging exists

Staging helps you choose what belongs in the next snapshot.

That matters when one file has good changes and messy changes together.

You can save the good part now and fix the rest later.

Common mistake: skipping staging

A common mistake is committing everything by accident. That can mix finished work with half-done work.

Staging fixes that because you pick exactly what goes into the commit.

So staging is not extra busywork. It gives you control.

Your turn: choose the right step

You fixed two bugs, but one file still has unfinished edits. What is the best Git move?

  1. Commit everything right away
  2. Stage only the finished fixes, then commit
  3. Delete the unfinished file
Show answer

Stage only the finished fixes, then commit: Correct. Stage only the finished fixes, then commit those.

The Git habit to remember

Keep this simple habit in mind: edit, stage, commit.

That loop is the heart of Git. It keeps your work safe and organized.

If you remember that, you already know the core of version control.

edit → stage → commit
Learn this with Leo, freeA voiced lesson with a live whiteboard, quizzes and a tutor you can call, at tutelage.app