Skip to main content

Command Palette

Search for a command to run...

Git for Beginners: Basics and Essential Commands

A practical beginner-friendly introduction to Git, its core terms, and the commands you need to start using it confidently

Updated
5 min read
Git for Beginners: Basics and Essential Commands
P
IT graduate 2024. Learning software and web development in public. Writing about bugs, fixes, small projects, useful tools, and lessons from building things step by step.

Introduction

Git beginners ko aksar thoda scary lagta hai.

Har jagah commands hi commands dikhti hain:

  • git init

  • git status

  • git add

  • git commit

  • git log

Aur beginner ka natural reaction hota hai:

"Itna sab kaise yaad rahega?"

Sach ye hai ki Git ko command list ki tarah yaad karne se confusion hoti hai.

Git ko workflow ki tarah samajhna zyada useful hota hai.


What Is Git?

Git ek distributed version control system hai.

Ye definition sahi hai, but beginner ke liye thodi abstract lag sakti hai.

Simple words mein:

Git project ke changes ko track karta hai aur tumhe uski history manage karne deta hai.

Yani Git dekh sakta hai:

  • kya badla

  • kab badla

  • kis checkpoint par save hua

  • aur zarurat padne par kaise compare ya restore karna hai


Why Git Is Used

Git isliye use hota hai kyunki software projects constantly change hote rehte hain.

Developers ko chahiye hota hai:

  • safe history

  • rollback

  • collaboration

  • clean checkpoints

Without Git ya version control:

  • file versions confuse ho sakte hain

  • changes lose ho sakte hain

  • team coordination difficult ho sakti hai

Git in problems ko structured way mein solve karta hai.


What "Distributed" Means in Simple Terms

Git distributed system hai, iska basic meaning ye samjho:

Har developer ke paas project ka apna local repository ho sakta hai.

Yani history sirf kisi ek central machine par depend nahi hoti.

Beginner level par bas itna yaad rakhna kaafi hai:

Git local machine par bhi powerful history maintain kar sakta hai.


Core Git Terminologies

Git use karne se pehle kuch basic terms clear honi chahiye.

Repository

Repository ya repo project ka Git-enabled folder hota hai jahan files aur history dono manage hoti hain.

Commit

Commit ek meaningful checkpoint hota hai.

Ye project history mein ek saved snapshot jaisa hota hai.

Branch

Branch ek separate line of work jaisi hoti hai.

Yeh useful hoti hai jab tum main history ko disturb kiye bina kaam karna chahte ho.

HEAD ek reference hota hai jo generally batata hai ki abhi tum kis current branch ya commit position par ho.

Beginner ke liye bas itna:

HEAD current position indicator jaisa samjho.


The Three Main Areas of Git

Git ka workflow samajhne ka easiest way hai yeh teen areas samajhna:

  • Working Directory

  • Staging Area

  • Repository

Working Directory

Yahi tumhari actual files hoti hain jahan tum edit karte ho.

Staging Area

Yeh next commit ki preparation zone hoti hai.

Yahan tum decide karte ho kaunse changes next checkpoint ka part banenge.

Repository

Yahan committed history store hoti hai.

Ye tumhara tracked record hota hai.

Working Directory -> Staging Area -> Repository

Common Git Commands

Ab important commands ko ek practical flow mein dekhte hain.

git init

git init

Ye command ek normal folder ko Git repository bana deti hai.

Yani ab Git us folder ke changes track kar sakta hai.

git status

git status

Ye beginner ka best friend hai.

Ye batata hai:

  • kaunse files modified hain

  • kaunse staged hain

  • kaunse untracked hain

Confuse ho? git status chalao.

git add

git add file-name

Ya:

git add .

git add commit nahi karta.

Ye sirf changes ko stage karta hai.

Simple meaning:

"In changes ko next commit mein include karna hai."

git commit

git commit -m "add initial project structure"

Ye staged changes ka checkpoint create karta hai.

Good commit message future understanding mein help karti hai.

git log

git log

Ye commit history dikhata hai.

Yani project ka evolution dekh sakte ho.

git diff

git diff

Ye exact changes dikhata hai before commit.

Beginners ke liye bahut useful hota hai.


A Basic Developer Workflow from Scratch

Chalo ek simple flow dekhte hain:

git init
git status
git add .
git commit -m "add initial project files"
git log

Yeh small workflow beginner ke liye kaafi powerful starting point hai.

Flow ko words mein samjho:

  1. project ko Git repo banao

  2. current situation dekho

  3. changes stage karo

  4. commit karo

  5. history check karo

Yehi beginner Git ka strong foundation hai.


Common Beginner Mistakes

git add aur git commit ko same samajhna

git add prepare karta hai. git commit save point banata hai.

Random commit messages

update, changes, final jaise messages later useless lagte hain.

git status ignore karna

Git ka current state samajhne ke liye ye command bahut important hai.

Workflow samjhe bina commands ratna

Ye short-term mein kaam kar sakta hai, but confidence build nahi karta.


Summary

  • Git ek distributed version control system hai

  • Git project changes aur history manage karta hai

  • repository, commit, branch, and HEAD basic important terms hain

  • working directory, staging area, aur repository ka flow samajhna very important hai

  • git init, git status, git add, git commit, and git log essential beginner commands hain


Final Thought

Git tab easy lagna start hota hai jab tum usse commands ki jungle ki tarah nahi, ek flow ki tarah dekhte ho.

Ek baar working directory se commit tak ka path clear ho gaya, Git suddenly much more logical lagne lagta hai.


Continue Reading

Git & Version Control

Part 2 of 3

A clear learning series on why version control exists, how Git works, and the essential concepts every developer should understand.

Up next

Inside Git: How It Works and the Role of the .git Folder

A beginner-friendly guide to what Git stores internally and how git add and git commit work behind the scenes