Version Control
What is Git?
Git is a free, open-source distributed version control system used to
track changes in code and collaborate with other developers.
It was created by Linus Torvalds (the creator of Linux) in 2005 to handle the
development of large projects with speed and efficiency.
Local and Remote:
• Local Git: Your personal copy of the code and its history on your
computer.
• Remote Git: A shared repository (like on GitHub, GitLab, or
Bitbucket) where teams sync their code.
What is Version Control?
Version control is a system that helps you track, manage, and control
changes to files over time — especially in code, documents, or any digital
content.
It’s like a “time machine” for your project, allowing you to:
• Save versions of your work
• Go back to previous versions if something breaks
• Collaborate with others without overwriting each other’s changes
Key Features of Version Control:
Feature Explanation
History Tracking
Keeps a full history of every change, who made it, and
when.
Undo Capability
Allows you to roll back to a working version if
something goes wrong.
Collaboration Multiple people can work on the same project without
conflict.
Branching and Developers can work in isolated branches and later
Merging merge them together.
Backup Provides a backup in case of accidental deletion or
corruption.
Types of Version Control Systems:
1. Local Version Control o Tracks changes
only on your computer o Example: RCS
(older)
2. Centralized Version Control (CVCS) o
One central server stores all versions o
Example: SVN, Perforce
3. Distributed Version Control (DVCS) o
Everyone has a full copy of the code and
history o Git is a DVCS — most widely
used today
Git Version Control Workflow:
1. Initialize a Repository
git init
Starts version control in your project folder.
2. Track Files
git add filename
Stages files for commit (adds them to the next snapshot).
3. Save a Snapshot (Commit)
git commit -m "Your message"
Creates a versioned snapshot of your code.
4. View Change History
git log
Shows all past commits with details.
5. Create a Branch
git checkout -b feature-login
Creates a separate version of your code to work on a new feature.
6. Merge Branches
git merge feature-login
Combines changes from one branch into another.
7. Push to Remote Repository
git push origin main
Sends local commits to GitHub or another platform.