Skip to content

Git Cheat Sheet: Git Commands की Complete Hinglish Guide

Updated 30 Sep 2026 4 min scan

Git क्या है?#

Git एक Version Control System (VCS) है जिसका इस्तेमाल developers अपने code और project files में होने वाले changes को track करने के लिए करते हैं।

Simple words mein:

Git आपके project की history को maintain करता है ताकि आप जान सकें कि क्या change हुआ, कब change हुआ और किसने change किया।

मान लीजिए आपने एक website बनाई।

आज आपने:

Code
index.html
style.css
script.js

बनाए।

कल आपने script.js में कुछ changes किए और उससे application खराब हो गई।

Git की मदद से आप पुराने working version को देख सकते हैं और जरूरत पड़ने पर उस version पर वापस जा सकते हैं।


Git क्यों जरूरी है?#

जब project छोटा होता है तो files की copies बनाकर काम चल सकता है:

Code
project-final
project-final-new
project-final-new-2
project-final-latest
project-final-latest-real

😄 लेकिन real projects में यह तरीका जल्दी messy हो जाता है।

Git इस problem को solve करता है।

Git की मदद से आप:

  • Changes track कर सकते हैं
  • पुराने versions देख सकते हैं
  • Previous version पर वापस जा सकते हैं
  • Multiple developers के साथ काम कर सकते हैं
  • Branch बना सकते हैं
  • Features को अलग-अलग develop कर सकते हैं
  • Code merge कर सकते हैं
  • Remote repository पर code push कर सकते हैं
  • Team के साथ collaboration कर सकते हैं

Git और GitHub में क्या difference है?#

यह बहुत common confusion है।

GitGitHub
Version Control SystemCode hosting platform
आपके computer पर चलता हैInternet पर hosted service
Changes track करता हैRepository host करता है
Local repository रखता हैRemote repository रखता है
git commitPull Request
git branchRepository collaboration

Simple example:

Code
Git = Tool
GitHub = Online Platform

GitHub के अलावा GitLab और Bitbucket जैसी services भी हैं।


Git कैसे काम करता है?#

Git को समझने के लिए तीन important areas समझिए:

Code
Working Directory
       ↓
Staging Area
       ↓
Git Repository

1. Working Directory

जहाँ आप actual files में changes करते हैं।

Example:

Code
index.html
style.css
app.js

2. Staging Area

जिसमें आप बताते हैं कि कौन से changes अगले commit में जाने चाहिए।

Code
git add index.html

3. Repository

जहाँ Git committed history store करता है।

Code
git commit -m "Add homepage"

इसलिए basic workflow:

Code
Edit
 ↓
git add
 ↓
git commit

Git Repository क्या है?#

Git repository वह project location है जहाँ Git project की history maintain करता है।

किसी existing project में Git initialize करने के लिए:

Code
git init

इसके बाद project में .git directory बनती है।

Code
my-project/
├── .git/
├── index.html
├── style.css
└── app.js

.git directory Git की internal information और history के लिए important होती है।


Git Install Check कैसे करें?#

Terminal में:

Code
git --version

Example:

Code
git version 2.x.x

अगर Git installed है तो version दिखाई देगा।


Git Configuration#

Git में अपना name और email configure करना useful है क्योंकि commits में author information record होती है।

Name

Code
git config --global user.name "Your Name"

Email

Code
git config --global user.email "you@example.com"

Configuration check करने के लिए:

Code
git config --global --list

Specific value देखने के लिए:

Code
git config user.name
Code
git config user.email

Git Repository Initialize करना#

किसी existing project को Git repository बनाने के लिए:

Code
git init

Example:

Code
mkdir my-project
cd my-project
git init

अब Git इस project को track कर सकता है।


Git Status Command#

सबसे useful Git commands में से एक:

Code
git status

यह बताता है:

  • कौन सी files modified हैं
  • कौन सी files staged हैं
  • कौन सी files untracked हैं
  • current branch कौन सी है

Example:

Code
git status

जब भी confusion हो, पहले git status चलाना एक अच्छी habit है।


Git Add Command#

Changes को staging area में add करने के लिए:

Code
git add filename

Example:

Code
git add index.html

Multiple files:

Code
git add index.html style.css

Current directory के सभी changes add करने के लिए:

Code
git add .

ध्यान रखें

Code
git add .

का मतलब है current directory के applicable changes को staging में add करना।

Commit करने से पहले:

Code
git status

से check कर लेना useful है।


Git Commit Command#

Staged changes को Git history में save करने के लिए:

Code
git commit -m "Add homepage"

यहाँ:

Code
commit

Git को change save करने के लिए कहता है।

और:

Code
-m "Add homepage"

commit message देता है।

Good commit message

Code
git commit -m "Add login page"
Code
git commit -m "Fix mobile navigation"
Code
git commit -m "Update product API"

Commit message ऐसा रखें जिससे बाद में समझ आए कि change क्या था।


Basic Git Workflow#

एक normal workflow:

Code
git status
git add .
git commit -m "Add new feature"

Mental model:

Code
Code Change
    ↓
git status
    ↓
git add
    ↓
Staging Area
    ↓
git commit
    ↓
Git History

Git Log#

Commits की history देखने के लिए:

Code
git log

Short version:

Code
git log --oneline

Example:

Code
a82f31a Add login page
91bd22c Fix navbar
72aa912 Initial commit

--oneline history को compact format में दिखाता है।


Git Diff#

Current changes देखने के लिए:

Code
git diff

यह बताता है कि files में क्या बदला है।

Staged changes देखने के लिए:

Code
git diff --staged

इससे commit करने से पहले changes review किए जा सकते हैं।


Git Clone#

Remote repository की local copy बनाने के लिए:

Code
git clone <repository-url>

Example:

Code
git clone https://github.com/user/project.git

इसके बाद:

Code
cd project

अब आप local project पर काम कर सकते हैं।


Git Remote#

Remote repositories देखने के लिए:

Code
git remote -v

Remote add करने के लिए:

Code
git remote add origin <repository-url>

यहाँ origin remote का commonly used name है।


Git Push#

Local commits को remote repository पर भेजने के लिए:

Code
git push

पहली बार branch push करते समय अक्सर:

Code
git push -u origin main

-u upstream relationship set करता है।

इसके बाद future में:

Code
git push

काफी हो सकता है।


Git Pull#

Remote repository से latest changes लेकर current branch को update करने के लिए:

Code
git pull

Simple workflow:

Code
Remote Repository
       ↓
   git pull
       ↓
Local Repository

Team project में काम करते समय push करने से पहले latest changes pull करना useful हो सकता है।


Git Fetch#

Remote से latest information download करने के लिए:

Code
git fetch

Difference समझिए:

Code
git fetch
↓
Remote information download करता है

git pull
↓
Fetch + integration करता है

अगर आप पहले remote changes inspect करना चाहते हैं तो git fetch useful हो सकता है।


Git Branch क्या है?#

Branch को project की अलग development line की तरह समझ सकते हैं।

Example:

Code
main
 │
 ├── feature-login
 ├── feature-payment
 └── bugfix-navbar

इससे आप main code को directly disturb किए बिना feature develop कर सकते हैं।


Current Branch Check करना#

Code
git branch

Current branch के सामने * दिखाई देता है।

Example:

Code
* main
  feature-login

New Branch बनाना#

Code
git branch feature-login

लेकिन यह command सिर्फ branch create करती है।

उस branch पर जाने के लिए:

Code
git switch feature-login

Branch Create और Switch Together#

Modern Git में:

Code
git switch -c feature-login

यह:

  1. नई branch बनाता है
  2. उसी branch पर switch करता है

Branch Switch करना#

Code
git switch main

या किसी existing branch पर:

Code
git switch feature-login

Branch Delete करना#

Merged local branch delete करने के लिए:

Code
git branch -d feature-login

Force delete:

Code
git branch -D feature-login

-D use करते समय सावधान रहें क्योंकि unmerged work खो सकता है।


Git Merge#

एक branch के changes दूसरी branch में combine करने के लिए:

Code
git switch main
git merge feature-login

Mental model:

Code
feature-login
      ↓
    merge
      ↓
     main

Merge conflict होने पर Git आपको बताएगा कि कौन से parts conflict कर रहे हैं।


Merge Conflict क्या है?#

जब Git automatically decide नहीं कर पाता कि दो changes में कौन सा version रखना है, तो merge conflict हो सकता है।

Example:

Code
<<<<<<< HEAD
Current code
=======
Incoming code
>>>>>>> feature-login

आपको manually correct code रखना होगा।

फिर:

Code
git add .
git commit

या situation के अनुसार merge process complete करें।


Git Restore#

Working tree में किए गए unstaged changes को restore करने के लिए:

Code
git restore filename

Example:

Code
git restore style.css

ध्यान दें: इससे uncommitted changes खो सकते हैं। इसलिए command use करने से पहले confirm करें कि changes की जरूरत नहीं है।


Git Reset#

Git में reset powerful command है और इसे carefully use करना चाहिए।

Staged file को staging area से हटाने के लिए:

Code
git reset HEAD filename

Modern Git में:

Code
git restore --staged filename

यह file के changes को delete नहीं करता; केवल staging से हटाता है।


Git Revert#

किसी पुराने commit के effect को reverse करने के लिए:

Code
git revert <commit-hash>

यह generally एक नया commit बनाकर previous change को reverse करता है।

Shared branches पर history को safely undo करने के लिए revert अक्सर useful approach होता है।


.gitignore क्या है?#

कुछ files को Git tracking से बाहर रखने के लिए .gitignore file use होती है।

Example:

Code
node_modules/
.env
dist/
*.log

Typical project में:

Code
my-project/
├── .git/
├── .gitignore
├── package.json
├── src/
└── README.md

.env क्यों ignore करते हैं?

.env में API keys, passwords या other secrets हो सकते हैं।

उन्हें public repository में commit नहीं करना चाहिए।


Git में Untracked File क्या है?#

अगर नई file बनाई गई है और Git अभी उसे track नहीं कर रहा:

Code
git status

में वह untracked दिखाई दे सकती है।

Example:

Code
Untracked files:
    app.js

Track करने के लिए:

Code
git add app.js

Git में Modified और Staged का Difference#

मान लीजिए आपने app.js change किया।

पहले:

Code
Modified

फिर:

Code
git add app.js

अब:

Code
Staged

फिर:

Code
git commit -m "Update app logic"

अब change commit history में चला गया।


Git में HEAD क्या है?#

HEAD generally उस commit को refer करता है जिस पर आपका current Git context/branch point कर रहा है।

Simple mental model:

Code
HEAD
 ↓
Current Commit
 ↓
Previous Commit
 ↓
Older Commit

Git commands जैसे git reset, git revert और git diff समझने में HEAD concept useful है।


Git Tags#

Specific commits को important version names देने के लिए tags use किए जा सकते हैं।

Example:

Code
git tag v1.0.0

Tags देखने के लिए:

Code
git tag

यह releases को identify करने में useful है।


Git Stash#

अगर आपके पास uncommitted changes हैं लेकिन temporarily branch switch करना है, तो:

Code
git stash

Changes temporarily stash हो जाते हैं।

बाद में:

Code
git stash pop

से वापस ला सकते हैं।

Stashes देखने के लिए:

Code
git stash list

Practical Git Workflow#

मान लीजिए आप किसी website में login feature बना रहे हैं।

Step 1: Repository clone करें

Code
git clone https://github.com/example/project.git
cd project

Step 2: New branch बनाएं

Code
git switch -c feature-login

Step 3: Code लिखें

Code
login.html
login.js
login.css

Step 4: Changes check करें

Code
git status

Step 5: Changes stage करें

Code
git add .

Step 6: Commit करें

Code
git commit -m "Add login feature"

Step 7: Remote पर push करें

Code
git push -u origin feature-login

इसके बाद team workflow के अनुसार Pull Request बनाया जा सकता है।


Daily Git Workflow#

एक developer के daily workflow को simple तरीके से:

Code
git pull
git status

काम करें:

Code
Write Code
    ↓
Test
    ↓
git status
    ↓
git add .
    ↓
git commit
    ↓
git push

लेकिन exact workflow team/project के rules पर depend कर सकता है।


Common Git Mistakes#

1. Commit से पहले status check न करना

Habit:

Code
git status

2. हर चीज़ git add . कर देना

पहले check करें कि कौन सी files stage होनी चाहिए।

Code
git status

3. Secrets commit करना

इन files को carefully handle करें:

Code
.env
credentials
private keys
API secrets

.gitignore का use करें।

4. बिना समझे git reset --hard चलाना

यह working changes को permanently discard कर सकता है।

Command use करने से पहले अच्छी तरह समझें कि आप क्या reset कर रहे हैं।

5. Poor commit messages

Bad:

Code
git commit -m "changes"

Better:

Code
git commit -m "Fix checkout validation"

6. सीधे main branch पर काम करना

Team projects में feature branches useful होती हैं:

Code
feature-login
feature-payment
bugfix-navbar

Useful Git Commands Quick Reference#

कामCommand
Git versiongit --version
Repository initializegit init
Repository clonegit clone <url>
Status checkgit status
Changes देखनाgit diff
Stage filegit add <file>
Stage allgit add .
Commitgit commit -m "message"
Historygit log
Short historygit log --oneline
Branch listgit branch
New branchgit branch <name>
Create + switchgit switch -c <name>
Switch branchgit switch <name>
Mergegit merge <branch>
Remote listgit remote -v
Pull changesgit pull
Fetch changesgit fetch
Push changesgit push
Stash changesgit stash
Restore stashgit stash pop
Create taggit tag <name>
Undo commit effectgit revert <hash>

Git Commands याद रखने का आसान तरीका#

पूरे Git को एक simple flow में याद रखें:

Code
START
  ↓
git clone / git init
  ↓
git status
  ↓
Make Changes
  ↓
git add
  ↓
git commit
  ↓
git push

Team project में:

Code
git pull
   ↓
Make Changes
   ↓
git add
   ↓
git commit
   ↓
git push

Branch-based development:

Code
main
 ↓
git switch -c feature
 ↓
Code
 ↓
add
 ↓
commit
 ↓
push
 ↓
Merge / Pull Request

Knowledge Check#

Q1. Git क्या है?

A. Programming Language
B. Version Control System
C. Database
D. Operating System

Answer: B

Q2. git add क्या करता है?

A. Remote repository delete करता है
B. Changes को staging area में रखता है
C. Branch delete करता है
D. Git install करता है

Answer: B

Q3. Commit बनाने के लिए कौन सा command use होता है?

A. git save
B. git commit
C. git push
D. git upload

Answer: B

Q4. Remote repository से changes लेने के लिए commonly कौन सा command use होता है?

A. git pull
B. git send
C. git upload
D. git copy

Answer: A

Q5. New branch create और switch करने के लिए कौन सा command useful है?

A. git branch -delete
B. git switch -c <name>
C. git new <name>
D. git create <name>

Answer: B


Practical Exercises#

Exercise 1 — अपना पहला Repository बनाएं

Code
mkdir git-practice
cd git-practice
git init

फिर एक file बनाएं:

Code
README.md

और:

Code
git status
git add README.md
git commit -m "Add README"

Exercise 2 — Branch Practice

Code
git switch -c feature-test

एक file बनाएं और commit करें:

Code
git add .
git commit -m "Add feature test"

फिर main पर वापस जाएँ:

Code
git switch main

Exercise 3 — Git History देखें

कम से कम 3 commits बनाकर:

Code
git log --oneline

चलाएँ और अपनी project history देखें।


Exercise 4 — Stash Practice

कुछ changes करें लेकिन commit न करें:

Code
git status

फिर:

Code
git stash

और बाद में:

Code
git stash pop

से changes वापस लाएँ।


Git सीखने के बाद क्या सीखें?#

The Easy Master learning path में Git के बाद GitHub आता है।

Recommended sequence:

Code
Computer Fundamentals
        ↓
Terminal / Shell
        ↓
Git
        ↓
GitHub
        ↓
Internet Fundamentals
        ↓
DNS
        ↓
HTTP / HTTPS
        ↓
Browser DevTools

Git के बाद GitHub सीखने से आपको local Git + remote collaboration दोनों concepts समझने में मदद मिलेगी।


Summary#

आसान भाषा में Git को ऐसे याद रखें:

Git आपके project की history और changes को manage करने वाला Version Control System है।

सबसे important commands:

Code
git init
git clone
git status
git add
git commit
git log
git branch
git switch
git merge
git pull
git fetch
git push
git stash
git revert

सबसे important workflow:

Code
Change
  ↓
Status
  ↓
Add
  ↓
Commit
  ↓
Push

और team development में:

Code
Pull
 ↓
Branch
 ↓
Code
 ↓
Test
 ↓
Commit
 ↓
Push
 ↓
Review / Merge

Git का goal commands याद करना नहीं है — बल्कि project changes को safely track और manage करना समझना है।