Introduction to Version Control

Git is a distributed version control system that tracks changes to your code over time, letting you save snapshots, work on features in separate branches, and undo mistakes.

Learn Introduction to Version Control in our free Git course — a beginner-friendly interactive lesson with worked examples, a practice exercise and a quick…

Part of the free Git course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.

By the end of this lesson you'll understand why version control exists, configure Git for the first time, and create your own repository with its first commit — the foundation every developer builds on.

What You'll Learn in This Lesson

1️⃣ What is Version Control?

Version control is a system that records changes to your files over time so you can review them, undo them, or work on them with other people. Without it, you end up with folders full of final_v2_ACTUALLY_FINAL.zip files. Git — created by Linus Torvalds (the creator of Linux) in 2005 — is the world's most popular version control system. It's distributed , meaning every developer keeps the project's full history on their own machine. A commit is a saved snapshot of your project, and the log below is a history of those snapshots.

2️⃣ Installing & Configuring Git

Git runs on every operating system. After installing, do the one-time setup : tell Git your name and email . Git stamps these onto every commit you make so your team (and future you) knows who changed what. The --global flag means you set them once for your whole machine, not per project.

Now finish the setup yourself. Replace each ___ using the 👉 hint, run the commands, and check your output against the Output panel.

3️⃣ Git's Three Areas

Understanding Git's three areas is the key to mastering it. The Working Directory is your actual files on disk. The Staging Area (also called the index) is where you line up exactly which changes go into the next commit. The Repository is the permanent, saved history. The flow is always the same: edit → git add (stage) → git commit (save) . Notice how git status below shows a file moving from "not staged" to "to be committed".

4️⃣ Your First Repository

Use git init to turn a folder into a repository, git add to stage files, and git commit to save a snapshot. Lean on git status constantly — it tells you exactly what state every file is in. Here's the whole cycle, start to finish.

Your turn to drive the whole cycle. Fill in the three blanks below, then run the commands in order — you'll go from an empty folder to a repository with one commit.

📋 Quick Reference — Essential Git Commands

No commands are filled in this time — just a brief and an outline. Work through it in your own terminal, then check your result against the expected output in the comments. This is exactly the loop you'll run at the start of every real project.

Practice quiz

What is Git?

  • A cloud hosting website like GitHub
  • A distributed version control system that tracks changes over time
  • A programming language
  • A code editor

Answer: A distributed version control system that tracks changes over time. Git is a distributed version control system; GitHub is a separate site that hosts Git repositories.

Which command turns the current folder into a new Git repository?

  • git init
  • git start
  • git new
  • git create

Answer: git init. git init creates a fresh .git directory, turning the folder into a repository.

In Git's three areas, where does git add move a changed file?

  • Into the repository history
  • Back to the working directory
  • Into the staging area
  • Onto a remote server

Answer: Into the staging area. git add moves changes from the working directory into the staging area, ready for the next commit.

Which command permanently saves the staged snapshot into the repository?

  • git save
  • git stage
  • git push
  • git commit

Answer: git commit. git commit records the staged snapshot into the repository history with a message.

What does git status show you?

  • What is changed, staged, or untracked
  • The full diff of every commit
  • A list of remote branches
  • Your global config values

Answer: What is changed, staged, or untracked. git status reports which files are modified, staged, or untracked right now.

Why must you run git add before git commit?

  • git add uploads files to GitHub
  • git add deletes old commits
  • Staging lets you choose exactly which changes go into the commit
  • It is only needed the first time

Answer: Staging lets you choose exactly which changes go into the commit. Staging separates choosing what to save from actually saving it, so a commit can include only some files.

What does the --global flag do in git config --global user.name?

  • Sets the name only for the current commit
  • Sets the name once for your whole machine
  • Pushes your name to the remote
  • Sets the name for everyone on the team

Answer: Sets the name once for your whole machine. --global stores the setting for your user account, so every repository on the machine uses it.

What is a commit?

  • A remote server copy
  • A branch label
  • A list of ignored files
  • A saved snapshot of your project at a point in time

Answer: A saved snapshot of your project at a point in time. Each commit is a permanent snapshot of your project that you can return to later.

Which command shows the commit history one line per commit?

  • git log --oneline
  • git history
  • git show --short
  • git commits

Answer: git log --oneline. git log --oneline prints a compact history with one short line per commit.

Which statement about Git being distributed is true?

  • You always need internet to commit
  • Only one person can hold the history
  • The full project history lives on your own machine and works offline
  • History is stored only on GitHub

Answer: The full project history lives on your own machine and works offline. Git is distributed: the complete history is on your computer, so init, add, commit, and log all work offline.