6 min read
📦beginner

What is Git? — Saving Your Work Like a Pro

Learn what version control is, why every developer uses Git, and how it saves you from losing your work forever.

The Problem Git Solves

Have you ever worked on an essay and saved copies like this? - essay.doc - essay_v2.doc - essay_final.doc - essay_final_ACTUALLY_FINAL.doc - essay_final_v2_REAL_FINAL.doc It is messy, confusing, and you never know which one is the real latest version. Now imagine this with code, where one project might have hundreds of files being changed by multiple people. Chaos! Git solves this by tracking every change you make, letting you go back to any previous version, and helping multiple people work on the same project without overwriting each other's work.

How Git Works (Simplified)

Think of Git like a time machine for your code. Every time you 'save' in Git (called a 'commit'), it takes a snapshot of ALL your files at that moment. You can: - See exactly what changed between any two snapshots - Go back to any previous snapshot if something breaks - Create 'branches' to try new ideas without messing up the main code - Merge your new ideas back in when they are ready Git stores all of this history locally on your computer, so you can work offline. And with services like GitHub, you can also store it online and share with others.

Your First Git Commands

bash
# Start tracking a project with Git
git init

# Check what has changed
git status

# Tell Git to track a file
git add myfile.js

# Save a snapshot with a message
git commit -m "Added the homepage layout"

# See the history of all your snapshots
git log
Pro Tip

Git is not the same as GitHub! Git is the tool that tracks changes on your computer. GitHub is a website where you can store your Git projects online and share them with others. Think of it this way: Git is like a camera (takes snapshots), and GitHub is like a photo album in the cloud (stores and shares them).

Try Git

If you have Git installed (check by typing 'git --version' in your terminal), create a new folder, run 'git init' inside it, create a simple text file, and make your first commit. Then change the file, commit again, and use 'git log' to see your two snapshots. You just created your first version history! If you do not have Git installed yet, go to git-scm.com to download it.

Ready to build?

Put what you learned into practice — pick a project and start coding.

Start Building Free