Git for Beginners: Basics and Essential Commands
What Is Git?
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?
- 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
- 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
mainormaster. - 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 logGet Shreyasmhatre’s stories in your inbox
Join Medium for free to get updates from this writer.
Basic Developer Workflow Using Git (From Scratch)
Step 1: Initialize a Repository
git initThis command:
- Creates a
.gitfolder - Turns your project into a Git repository
Step 2: Check Repository Status
git statusThis 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 logDisplays:
- Commit history
- Author
- Date
- Commit messages








