DEV Community

Ibrahim
Ibrahim

Posted on

Why do we need git

Have you ever been working on a school project or a piece of code, made a huge mistake, and realized you couldn't go back? Or maybe you saved a file as project_final.py, then project_final_v2.py, and finally project_actual_final_v3_STOP_CHANGING.py? It’s a nightmare!

This is exactly why Git was created. In this post, we’re going to look at what Git is, how it acts like a "time machine" for your work, and why it is the most important tool you will ever install on your computer.

What is Git?
In simple terms, Git is a Version Control System. That sounds fancy, but think of it like the "Version History" in Google Docs or a "Save Point" in a video game.

Git watches your folder and remembers every single change you make. If you write a line of code today and delete it tomorrow by accident, Git has a memory of exactly what that line was. It keeps your project's history organized so you never have to worry about losing your best ideas.

Why Should Anyone Care?
If you want to work in tech, Git is not optional—it’s a superpower! Here is why:

You Can Undo Anything: If your code breaks (and it will!), you can just tell Git to "go back to how it was 10 minutes ago."

Working Safely: You can create a "copy" of your project to test a new idea. If the idea fails, your main project stays perfectly safe.

Teamwork: If you are working with a friend in Kisumu and another in Nairobi, Git helps merge all your code together without overwriting each other's work.

It’s the Industry Standard: Every big company (like Google or Netflix) uses Git. Knowing it makes you look like a pro.

The Big 4 Concepts
To speak "Git," you only need to know these four words:

Repository (Repo): This is just a folder where Git is "watching" your files. It’s the home for your project.

Commit: This is like hitting the "Save" button, but with a note. You tell Git: "I am saving my work now, and I added the Login button."

Branch: This is a separate path. You can have a "Main" branch for your working app and a "Testing" branch for your crazy ideas.

Merge: This is when you take the good ideas from your "Testing" branch and put them back into your "Main" branch.

A Real-Life Example: The Lem-in Project
Imagine you are working on the Lem-in ant farm project. You have a "Brain" that finds the shortest path, and it works perfectly.

Now, you want to try a new, faster math trick (like Edmonds-Karp). Without Git, you might change your code, break everything, and forget how the old version worked. With Git, you just make a Commit of your working code. Then, you try the new trick. If it breaks, you just "Rollback" to your last commit, and your working ant farm is back instantly!

Getting Started
To start, you just need to install Git and use a few simple commands in your terminal:

git init: Starts a new Repo.

git add .: Tells Git to look at your changes.

git commit -m "My first save": Saves your work.

Top comments (0)