Sanudin Logo
← Back to blog

Git for Everyone: What Is Git, Repository, and Commit

#git#versioncontrol#programming#beginners

Series: Git for Everyone · Part 1 of 6 — What Is Git, Repository, and Commit

🕐 ~6 min read · Beginner friendly

📝 A note on this article · This post is based on my personal study notes on version control and Git collaboration. To make these notes more readable and useful — for myself and for others — I worked with AI to help expand and structure them into a proper blog format. The ideas, learning journey, and understanding are mine; the AI helped with the writing and presentation.


Why Should You Learn Git?

Imagine you're writing a story. You write a few pages, then decide to change the ending. But after changing it, you realize the original ending was actually better. Without a way to go back, you're stuck.

Now imagine you could save a "checkpoint" every time you like what you've written. If things go wrong, you just go back to the last checkpoint. That's essentially what Git does — but for code.

Git is a version control system: a tool that records every change you make to your files, so you can go back in time, collaborate with teammates, and never lose your work.


What Is a Repository?

The word repository comes from Latin, roughly meaning "a place to store things." Think of it as a warehouse for your project.

A Git repository (or "repo") is a folder that Git is watching. Every file inside it can be tracked, every change recorded, and the full history preserved.

There are two kinds of repositories you need to know:

🏠 Local Repository

This is the repo that lives on your own computer. You can add files, delete them, or edit them freely here. It's your personal workspace — like a draft notebook.

When you're offline and can't connect to the internet, your local repo is still fully functional.

☁️ Remote Repository

This is the repo stored on a server — usually a platform like GitHub, GitLab, or Bitbucket. Think of it as the "official copy" that everyone on your team can access.

The two repos stay connected through a Remote URL — basically the address of where the online repository lives. This connection lets you:

  • Push your local changes up to the remote
  • Pull the latest changes from the remote down to your computer

Analogy for kids: Your local repo is your sketchbook at home. The remote repo is the class bulletin board at school. You draw at home, then pin your work to the board for everyone to see.

What Can You Store in a Repository?

Almost anything! Text files, code, PDFs, images, audio, ZIP files — you name it. However, not every file will preview nicely on platforms like GitHub. The best-supported format is Markdown (.md), which is how files like README.md are rendered beautifully on GitHub.


Setting Up Git (Quick Start)

Before we go further, let's make sure Git is set up on your machine.

# Check if Git is installed
git --version

# Set your name (shows up in commit history)
git config --global user.name "Your Name"

# Set your email
git config --global user.email "you@example.com"

To start tracking a folder with Git:

# Navigate to your project folder
cd my-project

# Initialize a new Git repository
git init

You'll see a .git folder appear — that's Git's internal brain for your project.

To connect your local repo to a remote one (e.g., on GitHub):

git remote add origin https://github.com/your-username/your-repo.git

What Is a Commit?

A commit is a snapshot. Every time you commit, Git takes a picture of your project at that exact moment and saves it in the history.

Think of commits like save points in a video game. If you reach a difficult boss and you're about to try a risky strategy, you'd want to save first. If things go badly, you reload. Commits work the same way.

Each commit contains:

  • A snapshot of every tracked file
  • A timestamp of when it happened
  • A message describing what changed
  • A unique ID (called a hash) to identify it

Making Your First Commit

Here's the typical flow:

# Step 1: Check what files have changed
git status

# Step 2: Stage the files you want to include in the commit
git add index.html         # stage a specific file
git add .                  # stage everything

# Step 3: Commit with a message
git commit -m "Add homepage layout"

The -m flag lets you write the message inline. Always write a clear, descriptive message. Future you — and your teammates — will thank you.

What Makes a Good Commit Message?

❌ Bad✅ Good
fix stuffFix broken login redirect on mobile
updateUpdate README with setup instructions
asdfghAdd user profile page with avatar support

Viewing Commit History

# See all commits
git log

# A cleaner, one-line view
git log --oneline

# Show what changed in each commit
git log -p

The Staging Area: Git's "Draft Box"

One concept that surprises beginners: Git doesn't commit everything automatically. There's a middle step called the staging area (also called the index).

Think of it like packing a box before shipping:

  • Your working files are your room (messy, in progress)
  • The staging area is your packed box (what you're ready to send)
  • A commit is the shipped package (permanent, recorded)
# See what's staged vs. not staged
git status

# Unstage a file (take it out of the box)
git restore --staged index.html

Quick Reference

git init                        # Start a new repo
git remote add origin <url>     # Connect to a remote repo
git status                      # Check what's changed
git add <file>                  # Stage a file
git add .                       # Stage everything
git commit -m "your message"    # Save a snapshot
git log --oneline               # View commit history
git push origin main            # Send commits to remote
git pull origin main            # Get latest from remote

What's Next?

Now that you know what a repository is and how to make commits, the next step is learning how to travel through time — revisiting old commits, undoing mistakes, and branching off into parallel timelines.

Part 2: Traveling Through Time — Checkout, Reset, and Revert


📌 Series overview:

  • Part 1: What Is Git, Repository, and Commit ← you are here
  • Part 2: Traveling Through Time — Checkout, Reset, and Revert
  • Part 3: Branches, Stash, and Git Workflow
  • Part 4: Merge, Pull Requests, and Code Reviews
  • Part 5: Fork, Clone, and Open Source Collaboration
  • Part 6: Git GUI Apps — You Don't Have to Use the Terminal