DEV Community

Aritra Chatterjee
Aritra Chatterjee

Posted on

Git & GitHub 101: A Beginner's Guide to Version Control

Your friend leans over and says, "Just push it to GitHub." You smile. You nod. You have absolutely no idea what that means.

By the end of this blog, you won't just understand what it means — you'll be able to say it yourself, and explain it to someone else. Let's start from the very beginning.


First Things First: What is a Version Control System?

Before we talk about Git or GitHub, we need to understand the problem they solve.

Imagine you're building a website. You make some changes, something breaks, and now you can't remember what your code looked like before. Sound familiar?

A Version Control System (VCS) is a tool that tracks and manages changes to your files over time. Think of it as a time machine for your code — one that remembers every version of your project, so you can always go back.

With a VCS, you can:

  • Save different versions of your code
  • Revert to a previous version if something breaks
  • Collaborate with other developers without overwriting each other's work
  • Track who changed what, and when

The Three Types of Version Control Systems

Not all VCS tools work the same way. Here's how they've evolved:

Type How It Works Examples Key Trade-off
Local VCS Store versions only on your computer Simple, but zero collaboration support
Centralised VCS (CVCS) All versions live on one central server SVN, CVS Easy collaboration, but if the server goes down, everyone's stuck
Distributed VCS (DVCS) Every developer has a full copy of the project Git, Mercurial Fast, offline-friendly, and more secure — the modern standard

Git is a distributed VCS, which is exactly why it became the industry standard.


Meet Git

"Git is like Microsoft Word's Track Changes — but for your entire codebase, and about 100x more powerful."

Git is a distributed version control system created by Linus Torvalds in 2005 (yes, the same person who built the Linux kernel). It runs locally on your computer and takes snapshots of your project every time you save your progress.

Here's what makes Git special:

  • Fast — most operations happen on your own machine, no internet needed
  • Branching — you can create separate "versions" of your project to experiment freely
  • Backup built-in — every copy of a Git project is a full backup
  • Free and open source — used by millions of developers worldwide

So when someone says "commit your changes" — they mean Git just saved a snapshot of your code at that moment. Like a save point in a video game.

👉 Git Official Website


Meet GitHub

"Git is the tool. GitHub is where you put your work so the world can see it."

GitHub is a cloud-based platform that hosts your Git repositories online. While Git works on your computer, GitHub lets you:

  • Store your project in the cloud
  • Collaborate with a team
  • Review each other's code via Pull Requests
  • Track bugs and features with Issues
  • Connect to deployment pipelines with CI/CD integrations

The simplest way to remember the difference:

Git GitHub
What it is A version control tool A platform to host repositories
Where it runs Your local computer Online (browser/app)
Works offline? ✅ Yes ❌ Mostly no
Made by Linus Torvalds GitHub Inc.

So when someone says "push it to GitHub” — they mean: upload your Git snapshots to the cloud so others can see and access them.

👉 GitHub Official Website


The Core Concepts (With Real-World Analogies)

This is the part most beginner guides skip. Let's make sure the key ideas actually stick.

📁 Repository (Repo)

A repository is your project folder — but one that has a memory. It remembers every single change ever made to every file inside it.

"It's your project folder if your project folder kept a journal."

A repo can be local (on your computer) or remote (on GitHub).


📸 Commit

A commit is a saved snapshot of your project at a specific moment in time.

"Think of commits like save points in a video game. Git doesn't just save where you are — it remembers every save point you've ever made. Died at level 5? Roll back to level 3 and try again."

Every commit has a message describing what changed, like: "Added login page" or "Fixed the navbar bug".


🎭 Staging Area

Before you commit, you first decide what you want to include in the save.

"Imagine packing for a trip. You don't throw everything straight into the suitcase. First, you lay things out on the bed and decide what makes the cut. The bed is your staging area. git add is you deciding what goes in."


🌿 Branch

A branch is a parallel version of your project where you can experiment freely.

"Branches are like a parallel universe for your code. The main branch is your real, working world. You create a new branch to experiment — and whatever chaos happens there, stays there. It doesn't touch the main world until you decide to merge it back."

Git branch flow

Common example:

  • main → your stable, live code
  • feature-login → new login feature being built separately

The Basic Git Workflow

Here's what a typical day with Git looks like. Let's walk through it step by step, so nothing feels like magic.

basic git workflow


Step 1: Write or edit your code

Just work normally in your project folder. Nothing Git-specific yet.


Step 2: Stage your changes

git add .
Enter fullscreen mode Exit fullscreen mode

The . means "everything." You're telling Git: "Hey, watch all these files — I'm about to save them." Nothing is saved yet. You're just raising your hand.


Step 3: Commit your changes

git commit -m "Added login page"
Enter fullscreen mode Exit fullscreen mode

Now you're actually saving. The -m flag lets you write a message — a note to your future self (or teammates) explaining what changed. Think of it like adding a caption to a photo: "Here's the project on day 12, with the login page added."


Step 4: Push to GitHub

git push origin main
Enter fullscreen mode Exit fullscreen mode

Two things to know here:

  • origin — Git's nickname for your GitHub repository (the remote/online version of your project)
  • main — the branch you're pushing to (the primary, stable version)

So this line says: "Upload my saved changes to the main branch of my GitHub project."


Common Git Commands Cheat Sheet

Command What It Does
git init Start a new Git repository in your folder
git clone <URL> Download a repository from GitHub
git status See what's changed and what's staged
git add . Stage all changes
git commit -m "msg" Save a snapshot with a description
git push Upload your commits to GitHub
git pull Download the latest changes from GitHub
git branch View or create branches
git checkout -b <name> Create and switch to a new branch
git merge <branch> Merge a branch into your current one

Pro tip: Run git status constantly. It tells you exactly what state your files are in — which are untracked (red), which are staged (green), and whether you're ahead of GitHub.


Working With Branches

Creating a branch is one of the most powerful things you can do in Git. Here's how:

# Create a new branch
git branch feature-login

# Switch to it
git checkout feature-login

# Or do both in one command
git checkout -b feature-login
Enter fullscreen mode Exit fullscreen mode

Once your feature is ready, you merge it back into main:

git checkout main
git merge feature-login
Enter fullscreen mode Exit fullscreen mode

No chaos. No broken main code. Just clean, parallel development.


Conclusion

So — next time someone says "just push it to GitHub" — you've got them.

You now know that Git is the tool that tracks your changes locally, and GitHub is the platform that hosts your work online. You know what a commit is (a save point), what a branch is (a parallel universe for your code), and what staging means (packing your suitcase before the trip).

Git isn't just another tool you learn for fun. It's the tool every software team on the planet already uses. Mastering it doesn't just make you a better developer — it makes you a hireable one.

Now go initialise a repo. You've earned it.

git init
Enter fullscreen mode Exit fullscreen mode

Top comments (0)