CHAPTER 01
Introduction to Git and Version Control
Updated: May 15, 2026
15 min read
# CHAPTER 1
Introduction to Git and Version Control
1. Introduction
Welcome to the absolute foundation of modern software engineering. Whether you are building a simple one-page website or a massive enterprise application with thousands of developers, you will use Version Control. Version control is the system that records changes to a file or set of files over time so that you can recall specific versions later. Git is the undisputed king of version control systems. In this chapter, we will demystify what Git is, why every developer on earth uses it, and how to install and configure it on your machine.2. Learning Objectives
By the end of this chapter, you will be able to:- Define what a Version Control System (VCS) is.
- Understand the critical difference between Git and GitHub.
- Differentiate between Centralized and Distributed version control.
- Install Git on your local machine.
- Configure your global Git username and email address.
3. Beginner Explanation
Imagine you are writing a massive essay for school.-
The Old Way: You save files like
Essay.docx,EssayFinal.docx,EssayFinalReallyDone.docx,EssayFinalv2.docx. It is a chaotic mess. If you delete a paragraph on Monday and want it back on Friday, it is gone forever.
-
The Git Way: You just have one file:
Essay.docx. Every time you finish a section, you tell Git to take a "Snapshot" of the file. Git silently saves the exact state of that file. If you mess up on Friday, you can tell Git, "Put the file back exactly how it looked on Monday."
Git is a magical time machine for your code.
4. Git vs. GitHub
This is the most common confusion for beginners.- Git is the actual software installed on your local computer. It is the time machine engine. It works completely offline.
- GitHub is a website (owned by Microsoft) that hosts Git repositories in the cloud. It is a place to back up your code and share it with other developers.
5. Centralized vs. Distributed Systems
- Centralized (e.g., SVN): There is one master server holding all the code. To work, you must be connected to the internet. If the server crashes, nobody can work.
- Distributed (Git): When you download a project using Git, you download the *entire history* of the project to your local hard drive. Every developer has a full, complete backup. You can work perfectly offline on an airplane.
6. Mini Project: Install Git and Configure
Before we can track code, we need to set up the tool.Step-by-Step Walkthrough:
-
1.
Download: Go to
git-scm.comand download the installer for your OS (Windows/Mac/Linux). Install it using the default settings.
- 2. Open Terminal: Open your terminal (Mac/Linux) or "Git Bash" (Windows).
- 3. Verify Installation:
bash
git --version
`
-
4.
Configuration: Git needs to know who you are so it can attach your name to the code you write.
`bash
git config --global user.name "John Doe"
git config --global user.email "johndoe@example.com"
`
7. Best Practices
-
Use the Terminal: While there are graphical user interfaces (GUIs) for Git (like GitHub Desktop or GitKraken), you should learn Git using the command line first. GUIs hide what is actually happening. If something breaks, the command line is the only way to truly understand and fix the underlying issue.
8. Common Mistakes
-
Incorrect Email: Ensure the email you set in
git config` exactly matches the email you use to sign up for your GitHub account. If they do not match, your commits will not be properly linked to your GitHub profile, and you won't get the green contribution squares on your profile graph!
9. Exercises
- 1. What is the fundamental difference between Git and GitHub?
- 2. Why is Git considered a "Distributed" Version Control System?