This chapter covers the fundamental concepts of Git, explains its purpose, and defines the key vocabulary needed to understand the version control workflow.
1. What is Version Control?
Version Control is a system that records changes to a file or set of files over time so that you can recall specific versions later. It’s like having an “undo” button for your entire project, preserving every state your code has ever been in.
The Problem Solved by Git:
- Collaboration: Allows multiple developers to work on the same codebase simultaneously without overwriting each other’s work.
- Tracking History: Knowing who made what change, when, and why (via commit messages).
- Rollbacks: The ability to revert the entire project or a specific file back to any previous point in time.
- Experimentation: Creating isolated environments (branches) to develop new features or fix bugs without affecting the stable code.
2. What is Git?
Git is the most widely used, modern, and distributed Version Control System (VCS).
- Distributed: Unlike older centralized systems, every developer who clones a repository gets a full copy of the entire history of the project. This means you can commit changes and manage history locally even if you’re offline.
- Snapshots, Not Differences: Git doesn’t store data as a set of changes (diffs). Instead, every time you commit, Git takes a snapshot of what all your files look like at that moment and stores a reference to that snapshot. If a file hasn’t changed, Git simply links back to the previous identical file.
3. Git vs. GitHub (The Key Distinction)
These terms are often confused, but they serve different roles:
| Term | Role | Description |
| Git | The Tool (Local VCS) | The software installed on your computer that handles version control, snapshots, branching, and merging locally. |
| GitHub | The Service (Remote Host) | A cloud-based hosting service for Git repositories. It provides collaboration features, code review tools, issue tracking, and a centralized location to share your Git history with others. |
| Repository (Repo) | The Project Folder | The database where Git stores all your files and the complete history of every commit. |
4. Git Installation
Before using Git commands, you must ensure the software is installed on your operating system.
- Linux (Debian/Ubuntu):
sudo apt install git - Mac (using Homebrew):
brew install git - Windows: Download and run the Git for Windows installer (which includes the Git Bash command-line interface).
5. Essential Initial Configuration
After installation, you need to tell Git who you are. This information is attached to every commit you make.
- Set Your Name:
git config --global user.name "Your Name Here" - Set Your Email:
git config --global user.email "youremail@example.com"
Note: The--globalflag ensures these settings apply to all Git repositories on your computer. - Check Configuration:
git config --list
