DEV Community

Hardik Jain
Hardik Jain

Posted on

Why Git Version Control (VCS) Exists: The Pendrive Problem

What is Git ?

Git is a distributed version control system that helps developers track changes made to their code over time. It allows you to save different versions of a project, collaborate with others without overwriting each other's work, and easily restore previous versions . Instead of creating multiple copies of a project, Git manages all changes in an organized and efficient way.

What is Github?

GitHub is a cloud-based platform where developers store, manage, and share their Git repositories. It makes collaboration easy by allowing multiple people to work on the same project, track changes, review code, and contribute from anywhere. Think of Git as the tool that manages your code history, and GitHub as the online place where that code is stored and shared.

Why Version Control Exists?

Before Git, developers usually shared projects using pendrives, CDs, emails, or ZIP files. It worked fine when only one person was working on the project, but as soon as multiple people started making changes, things became messy.

Example: The Pendrive Problem

Imagine you and your friend are building a Restaurant Management System.

  • On Monday, you copy the project to a pendrive and give it to your friend.
  • Your friend adds the Login feature.
  • Meanwhile, you continue working on your own copy and add the Menu Management feature.
  • On Wednesday, your friend returns the pendrive.

Now you have two different versions of the same project.
Your Copy
├── Menu Management ✅
└── Login ❌

Friend's Copy
├── Login ✅
└── Menu Management ❌

Now the confusion starts:

  • Which project should you keep?
  • How do you combine both changes?
  • What if both of you edited the same file?

Many developers solved this by creating folders like:

  1. Restaurant_Project
  2. Restaurant_Project_Final
  3. Restaurant_Project_Final_v2
  4. Restaurant_Project_Final_Latest
  5. Restaurant_Project_Really_Final

After a few weeks, nobody knew which folder was actually the latest.

This is exactly why Version Control was created. Instead of creating multiple copies of a project, it keeps a complete history of every change, helps developers combine their work safely, and allows them to go back to older versions whenever needed.

Git Commands and their functionality

1. git init

git init tells Git, "Start tracking this project." It creates a hidden .git folder inside your project, where Git stores all the information needed to track changes, commits, branches, and project history.

2. git add

git add tells Git, "I want to include these changes in my next commit." It places the selected files in the staging area, where they wait to be committed.

3. git add.

git add . tells Git, "Stage all the changes in the current folder and its subfolders for the next commit." Instead of adding files one by one, it adds all new, modified, and deleted files at once.

4. git commit

git commit tells Git, "Save these staged changes as a new version of my project." It creates a permanent snapshot of your project, along with a message describing what changed

Example-

git commit -m "Added login feature"

Top comments (0)