Sitemap

Git for Beginners: Basics and Essential Commands

2 min readJan 17, 2026

--

What Is Git?

Press enter or click to view image in full size

Git is a distributed version control system (DVCS). In simple terms, it helps developers track changes in their code, collaborate with others, and roll back to previous versions if needed. Unlike traditional systems, Git doesn’t rely on a central server — every developer has a full copy of the project history on their machine.

Why Is Git Used?

Press enter or click to view image in full size
  • Collaboration: Multiple developers can work on the same project without overwriting each other’s work.
  • Version Tracking: Every change is recorded, so you can revisit or undo mistakes.
  • Branching: Experiment with new features in isolation without affecting the main project.
  • Speed & Efficiency: Git is lightweight and fast, even for large projects

Git Basics and Core Terminologies

Press enter or click to view image in full size
  • Repository (Repo): A project folder tracked by Git. It contains all files and the history of changes.
  • Commit: A snapshot of your project at a given time. Each commit has a unique ID.
  • Branch: A separate line of development. The default branch is usually called main or master.
  • HEAD: A pointer to your current branch and commit. It tells Git “where you are” in the project history.
  • Staging Area: A middle ground where changes are prepared before being committed.

Common Git Commands

# 1. Initialize a repository
git init
# 2. Check the status of your files
git status
# 3. Add files to the staging area
git add filename.txt
git add . # adds all files
# 4. Commit changes with a message
git commit -m “Initial commit”
# 5. View commit history
git log

Get Shreyasmhatre’s stories in your inbox

Join Medium for free to get updates from this writer.

Basic Developer Workflow Using Git (From Scratch)

Press enter or click to view image in full size

Step 1: Initialize a Repository

git init

This command:

  • Creates a .git folder
  • Turns your project into a Git repository

Step 2: Check Repository Status

git status

This Shows:

  • Modified files
  • Staged files
  • Untracked files

Step 3: Add Files to Staging Area

git add filename

# Or add everything:

git add .

Step 4: Commit Changes

git commit -m “Initial commit”

Step 5: View Commit History

git log

Displays:

  • Commit history
  • Author
  • Date
  • Commit messages

--

--