Skip to content

Git Cheat Sheet: Commands, Git Basics & Git Workflow in Hinglish

Updated 26 Sep 2026 6 min scan

Git क्या है?#

Git एक distributed version control system है, जिसका use developers code और project files में होने वाले changes को track करने के लिए करते हैं।

Simple words में, Git आपको यह जानने में help करता है:

  • किस file में क्या change हुआ?
  • Change किसने किया?
  • Change कब किया?
  • पुराने version पर वापस कैसे जाएँ?
  • अलग-अलग features पर independently कैसे काम करें?
  • Multiple developers के changes को कैसे combine करें?

Example से समझते हैं।

मान लीजिए आपने एक website बनाई और आज आपने उसमें 20 files में changes किए। कुछ देर बाद आपको पता चलता है कि एक important feature टूट गया है।

अगर Git use नहीं कर रहे हैं, तो पुराने code को manually ढूँढना मुश्किल हो सकता है।

लेकिन Git के साथ आप पुराने commits देख सकते हैं और जरूरत पड़ने पर previous version पर वापस जा सकते हैं।

याद रखने वाली बात:

Git = Code और project changes को track और manage करने का system.


Git क्यों सीखना चाहिए?#

आज लगभग हर software development workflow में version control important है।

Git सीखने के बाद आप:

  • अपने project का history maintain कर सकते हैं।
  • गलत changes को identify कर सकते हैं।
  • पुराने versions देख सकते हैं।
  • अलग-अलग features पर branches बना सकते हैं।
  • Team के साथ code collaborate कर सकते हैं।
  • GitHub जैसे platforms पर code push कर सकते हैं।
  • Pull Requests के through code review कर सकते हैं।
  • Deployment और CI/CD workflows में Git का use कर सकते हैं।

अगर आप developer बनना चाहते हैं, तो Git commands और Git workflow दोनों समझना useful है।


Git और Version Control क्या है?#

Version Control एक ऐसा system है जो files में होने वाले changes का history maintain करता है।

इसे ऐसे समझिए:

Code
Project
   ↓
Change
   ↓
Save Version
   ↓
More Changes
   ↓
Save Another Version
   ↓
Need Old Version?
   ↓
Restore / Inspect History

Git इसी process को efficiently manage करता है।

Version Control के बिना

Code
project-final.zip
project-final-new.zip
project-final-new-2.zip
project-final-new-final.zip
project-final-final-real.zip

ऐसा करना जल्दी confusing हो सकता है।

Git के साथ

Code
Commit 1
   ↓
Commit 2
   ↓
Commit 3
   ↓
Commit 4

हर commit project history का एक recorded point होता है।


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

Git को समझने के लिए सबसे important चीज़ है उसका basic workflow।

Code
Working Directory
       ↓
     git add
       ↓
Staging Area
       ↓
   git commit
       ↓
Git Repository
       ↓
   git push
       ↓
Remote Repository

अब इन चार concepts को समझते हैं।


Working Directory क्या है?#

Working Directory आपके project की current files होती हैं जिन पर आप currently काम कर रहे हैं।

Example:

Code
my-project/
├── index.html
├── style.css
├── script.js
└── README.md

आप script.js में change करते हैं।

यह change सबसे पहले आपकी Working Directory में होता है।


Staging Area क्या है?#

जब आप कोई change Git में commit करने के लिए select करते हैं, तो उसे Staging Area में add करते हैं।

इसके लिए:

Code
git add script.js

अब Git को पता है कि script.js का current change next commit में include करना है।

आप multiple files भी stage कर सकते हैं:

Code
git add .

git add . current directory के relevant changes को staging area में add करता है।


Commit क्या है?#

Commit project changes का एक recorded snapshot होता है।

जब आपने changes stage कर दिए:

Code
git commit -m "Add login form"

अब Git इस change को project history में record कर देता है।

Simple flow:

Code
File Change
    ↓
git add
    ↓
Staging Area
    ↓
git commit
    ↓
Commit History

Good commit message

Code
git commit -m "Add user login form"

Bad commit message

Code
git commit -m "changes"

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


Repository क्या है?#

Git repository एक project का Git-managed area है जिसमें Git project की history और metadata maintain करता है।

जब आप किसी project में Git initialize करते हैं:

Code
git init

तो current directory Git repository बन जाती है।

इसके बाद Git project में changes track कर सकता है।


Git Repository कैसे बनाएं?#

मान लीजिए:

Code
mkdir my-project
cd my-project

अब Git initialize करें:

Code
git init

Git एक .git directory create करता है।

Code
my-project/
└── .git/

.git directory Git की internal repository information रखती है।

Important: .git directory को manually delete या modify करने से बचें।


Git की Basic Workflow#

एक normal Git workflow कुछ ऐसा हो सकता है:

Code
1. Project create/open करें
        ↓
2. Git repository initialize/clone करें
        ↓
3. Files में changes करें
        ↓
4. git status
        ↓
5. git add
        ↓
6. git commit
        ↓
7. git push

Practical example:

Code
git status
git add .
git commit -m "Add homepage"
git push

Git Install है या नहीं कैसे Check करें?#

Terminal में:

Code
git --version

Example output:

Code
git version 2.x.x

Exact version आपके system पर अलग हो सकती है।

अगर command नहीं मिलती, तो आपके system में Git install या PATH configuration की आवश्यकता हो सकती है।


Git Configuration#

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

User 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 --global user.name

और:

Code
git config --global user.email

git init#

Current directory को Git repository बनाने के लिए:

Code
git init

Example:

Code
mkdir my-project
cd my-project
git init

कब use करें?

जब आपके पास local project है और उसमें अभी Git repository नहीं बनी है।


git clone#

Remote repository की copy अपने computer पर लाने के लिए:

Code
git clone <repository-url>

Example:

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

यह repository को local machine पर clone करता है।

Simple difference:

Code
git init
→ Existing local project में Git शुरू करना

git clone
→ Existing remote repository की copy लेना

git status#

Git की current स्थिति देखने के लिए सबसे useful commands में से एक है:

Code
git status

यह आपको बता सकता है कि:

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

Example:

Code
On branch main

Changes not staged for commit:
  modified: app.js

अगर आप unsure हैं कि Git में अभी क्या हो रहा है, तो:

Code
git status

से शुरुआत करें।


git add#

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 stage करने के लिए:

Code
git add .

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

Code
Working Directory
       ↓
    git add
       ↓
Staging Area

यह अभी commit नहीं करता।


git commit#

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

Code
git commit -m "Add homepage"

यहाँ:

Code
-m

commit message specify करता है।

Example:

Code
git add .
git commit -m "Add contact page"

git log#

Commit history देखने के लिए:

Code
git log

Short version:

Code
git log --oneline

Example:

Code
a12bc34 Add login page
d45ef67 Fix navbar
f78ab90 Initial commit

यह quick history देखने के लिए काफी useful है।


git diff#

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

Code
git diff

यह उन changes को दिखाता है जो अभी staged नहीं हैं।

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

Code
git diff --staged

Simple difference:

Code
git diff
→ Unstaged changes

git diff --staged
→ Staged changes

Git Branch क्या है?#

Branch project development की एक अलग line होती है।

मान लीजिए आपकी main application stable है और आपको login feature बनाना है।

आप सीधे main branch पर काम करने के बजाय नई branch बना सकते हैं:

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

इससे अलग-अलग features independently develop किए जा सकते हैं।


Current Branch कैसे देखें?#

Code
git branch

जिस branch के आगे * होगा, वह current branch है।

Example:

Code
* main
  login
  payment

New Branch बनाना#

Code
git branch login

यह branch create करता है लेकिन automatically उस branch पर switch नहीं करता।

Branch create और switch दोनों एक साथ करने के लिए:

Code
git switch -c login

यह modern Git workflow में convenient तरीका है।


Branch पर Switch करना#

Code
git switch login

पुराने workflow में यह command भी commonly मिलती है:

Code
git checkout login

लेकिन branch switching के लिए git switch अधिक focused command है।


Branch Delete करना#

Local branch delete करने के लिए:

Code
git branch -d login

अगर branch fully merged नहीं है और आप उसे force delete करना चाहते हैं:

Code
git branch -D login

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


Branch Naming#

Feature branch के लिए readable names रखें:

Code
feature/login
feature/payment
feature/user-profile
bugfix/navbar
hotfix/payment-error

Team में branch naming convention पहले से defined हो तो वही follow करें।


Git Merge क्या है?#

Merge दो branches के changes को combine करता है।

Example:

Code
main
  │
  └── feature/login

Login feature complete होने के बाद उसे main में merge किया जा सकता है।

पहले main branch पर जाएँ:

Code
git switch main

फिर:

Code
git merge feature/login

अब Git feature branch के changes को main branch में integrate करने की कोशिश करेगा।


Merge Conflict क्या है?#

जब Git automatically determine नहीं कर पाता कि दो branches के conflicting changes को कैसे combine करना है, तो merge conflict हो सकता है।

Example:

Code
main:
title = "Welcome"

feature:
title = "Hello"

अगर दोनों branches में same line अलग तरीके से बदली गई है, तो Git को choice चाहिए।

Conflict आने पर file में markers दिखाई दे सकते हैं:

Code
<<<<<<< HEAD
Welcome
=======
Hello
>>>>>>> feature/login

आपको manually decide करना होता है कि final content क्या होना चाहिए।

फिर:

Code
git add .
git commit

या merge operation के context के अनुसार Git द्वारा बताए गए next command को use करें।


Git Rebase क्या है?#

Rebase commits को दूसरी base पर replay करने का तरीका है।

Simple mental model:

Code
Before:

main:     A---B
               \
feature:        C---D

अगर feature को latest main के ऊपर rebase किया जाए:

Code
After:

main:     A---B
             \
feature:      C'---D'

Rebase history को linear रखने में help कर सकता है।

Basic command:

Code
git switch feature
git rebase main

Merge vs Rebase

MergeRebase
Branch histories combine करता हैCommits को नई base पर replay करता है
Merge commit create हो सकता हैLinear history maintain करने में मदद कर सकता है
Existing commits को rewrite नहीं करताCommit history rewrite हो सकती है
Team workflows में commonClean history के लिए useful

Important: Rebase के दौरान rewritten commits की वजह से shared/public history पर extra care चाहिए।


Git Remote क्या है?#

Remote एक दूसरे repository location को represent करता है जिसके साथ आपका local Git repository communicate कर सकता है।

Common remote name:

Code
origin

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

Code
git remote -v

Example:

Code
origin  https://github.com/user/project.git (fetch)
origin  https://github.com/user/project.git (push)

git remote add#

Local repository में remote add करने के लिए:

Code
git remote add origin <repository-url>

Example:

Code
git remote add origin https://github.com/user/project.git

फिर:

Code
git remote -v

से verify कर सकते हैं।


git fetch#

Remote repository से latest information लाने के लिए:

Code
git fetch

यह remote updates को local repository में fetch करता है, लेकिन सामान्यतः आपके current working files में उन changes को automatically merge नहीं करता।

Simple:

Code
git fetch
→ Remote information लेकर आता है

git pull
→ Fetch + integration workflow

git pull#

Remote से changes लेकर current branch में integrate करने के लिए:

Code
git pull

या:

Code
git pull origin main

यह command आपके workflow और Git configuration के अनुसार fetch के बाद merge या configured rebase कर सकती है।

इसलिए git pull को blindly run करने के बजाय समझें कि आपकी branch और remote कैसे configured हैं।


git push#

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

Code
git push

पहली बार किसी new branch को remote पर push करते समय:

Code
git push -u origin feature/login

यह local branch को remote branch से track करने में help करता है।

इसके बाद अक्सर:

Code
git push

काफी होता है।


First Git Push का Practical Workflow#

मान लीजिए आपने local project बनाया है और remote repository भी available है।

Code
git init

फिर files add करें:

Code
git add .

Commit करें:

Code
git commit -m "Initial commit"

Remote add करें:

Code
git remote add origin <repository-url>

फिर branch और remote setup के according push करें:

Code
git push -u origin main

अब आपका local commit remote repository तक पहुँच सकता है।


.gitignore क्या है?#

हर file को Git में track करना जरूरी नहीं होता।

कुछ files या folders को repository से बाहर रखना चाहिए, जैसे:

Code
node_modules/
.env
build/
dist/

इसके लिए project root में:

Code
.gitignore

file बनाई जाती है।

Example:

Code
node_modules/
.env
dist/

.gitignore क्यों जरूरी है?

यह accidentally sensitive या unnecessary files को commit करने से बचाने में help करता है।

Important: .gitignore में .env लिखना useful हो सकता है, लेकिन अगर secret पहले ही commit हो चुका है तो सिर्फ .gitignore add करने से वह पुराने Git history से automatically remove नहीं होता।


Git में File Rename करना#

Git-aware rename के लिए:

Code
git mv old-name.txt new-name.txt

फिर:

Code
git commit -m "Rename file"

आप normal filesystem command से भी rename कर सकते हैं और फिर git status के through changes stage कर सकते हैं।


Git में File Delete करना#

Git से tracked file delete करने के लिए:

Code
git rm file.txt

फिर commit:

Code
git commit -m "Remove unused file"

git restore#

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

Code
git restore filename

यह command सावधानी से use करें क्योंकि local changes discard हो सकते हैं।

Staged file को unstage करने के लिए:

Code
git restore --staged filename

इससे file staging area से हट जाएगी, लेकिन working directory का change बना रह सकता है।


Commit को Undo करने के Basic तरीके#

Git में “undo” का तरीका इस बात पर depend करता है कि change कहाँ तक पहुँचा है।

Staged change को unstage करना

Code
git restore --staged filename

Last commit को inspect/modify करना

अगर आपने अभी commit किया है और उसमें कुछ add करना है:

Code
git commit --amend

Public/shared history के लिए

Shared history को rewrite करने से पहले सावधानी रखें।

ऐसे cases में git revert अक्सर safer approach हो सकता है क्योंकि यह एक नया commit बनाकर previous change को reverse करता है।

Code
git revert <commit-hash>

git revert vs git reset#

CommandBasic purpose
git revertExisting commit को reverse करने वाला नया commit बनाता है
git resetCurrent branch pointer/history को move कर सकता है
git restoreWorking/staging files के changes manage करता है

याद रखने वाली बात

Code
restore → Files
revert → New reverse commit
reset → Branch/history position

reset के अलग modes और behaviors होते हैं, इसलिए इसे shared branches पर carefully use करना चाहिए।


Git Reset के Common Modes#

Git में commonly:

Code
git reset --soft
git reset --mixed
git reset --hard

इनका behavior अलग होता है।

ModeBasic effect
--softHEAD move करता है, changes staged रह सकते हैं
--mixedHEAD move करता है और changes unstaged हो सकते हैं
--hardHEAD और working tree को target state पर ले जाता है

Important: git reset --hard local uncommitted changes को discard कर सकता है। इसे बिना समझे use न करें।


Git Stash क्या है?#

कभी-कभी आप current work को commit नहीं करना चाहते लेकिन branch switch करना जरूरी है।

ऐसे में git stash useful हो सकता है।

Code
git stash

यह current changes को temporarily stash कर सकता है।

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

Code
git stash list

Latest stash वापस apply करने के लिए:

Code
git stash pop

Example scenario:

Code
आप feature/login पर काम कर रहे हैं
        ↓
अचानक production bug आ गया
        ↓
Current changes commit नहीं करने
        ↓
git stash
        ↓
Bug fix branch पर switch

Git Tag क्या है?#

Tag किसी specific commit को एक meaningful name देने के लिए useful है।

Example:

Code
git tag v1.0.0

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

Code
git tag

Remote पर tag push करने के लिए:

Code
git push origin v1.0.0

Tags अक्सर releases या important versions identify करने के लिए use होते हैं।


Git Cherry-Pick क्या है?#

अगर आपको किसी दूसरे branch के specific commit को current branch में apply करना है, तो:

Code
git cherry-pick <commit-hash>

Example:

Code
git cherry-pick a12bc34

यह पूरे branch को merge करने के बजाय selected commit को apply करने के लिए useful हो सकता है।


Git Alias क्या है?#

Frequently used commands को short बनाने के लिए Git aliases use किए जा सकते हैं।

Example:

Code
git config --global alias.st status

अब:

Code
git st

चलाने पर:

Code
git status

जैसा result मिल सकता है।


Git Branch Workflow#

एक simple feature development workflow:

Code
main
 │
 ├── feature/login
 │       │
 │       ├── changes
 │       ├── git add
 │       └── git commit
 │
 └── merge/review
         ↓
       main

Practical commands:

Code
git switch main
git pull

git switch -c feature/login

# Make changes

git status
git add .
git commit -m "Add login feature"

git push -u origin feature/login

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


Git और GitHub में Difference#

Beginners अक्सर Git और GitHub को same समझ लेते हैं।

लेकिन दोनों अलग हैं।

GitGitHub
Version control systemGit repository hosting/collaboration platform
Local machine पर चलता हैOnline service/platform
Commits और branches manage करता हैRepositories, Pull Requests, Issues आदि provide करता है
Internet के बिना भी बहुत-सा local workflow possible हैRemote collaboration के लिए useful

Simple words में:

Code
Git
↓
Version Control

GitHub
↓
Git repositories + Collaboration

Git पहले समझें, फिर GitHub workflow समझना आसान होगा।


GitHub Workflow#

एक common team workflow:

Code
Clone Repository
      ↓
Create Branch
      ↓
Make Changes
      ↓
git add
      ↓
git commit
      ↓
git push
      ↓
Pull Request
      ↓
Code Review
      ↓
Merge

यह exact process हर company में अलग हो सकता है, लेकिन basic Git concepts similar रहते हैं।


Common Git Errors#

fatal: not a git repository

Example:

Code
fatal: not a git repository

इसका मतलब अक्सर आप ऐसी directory में command चला रहे हैं जहाँ Git repository available नहीं है।

Check करें:

Code
git status

और सही project directory में जाएँ:

Code
cd project-folder

nothing to commit, working tree clean

अगर आपको यह message मिलता है:

Code
nothing to commit, working tree clean

तो Git के हिसाब से current working tree में commit करने के लिए कोई new change नहीं है।


Your branch is ahead of 'origin/main'

इसका मतलब local branch में ऐसे commits हो सकते हैं जो अभी remote branch पर push नहीं हुए हैं।

Check:

Code
git status

और जरूरत हो तो:

Code
git push

Merge Conflict

Conflict होने पर:

  1. Conflicted files identify करें.
  2. File खोलें.
  3. Conflict markers समझें.
  4. Correct final code रखें.
  5. File stage करें.
Code
git add <file>

फिर merge/rebase के context के अनुसार operation continue करें।


Common Git Mistakes#

1. बिना git status देखे commands चलाना

Habit बनाएं:

Code
git status

2. Meaningless commit messages

Avoid:

Code
git commit -m "update"

Better:

Code
git commit -m "Fix login validation"

3. Secrets commit करना

इन files में secrets हो सकते हैं:

Code
.env
credentials.json
private keys
API secrets

Sensitive data repository में commit करने से बचें।

4. git push --force blindly करना

Force push shared branch की history को affect कर सकता है।

इसे समझकर और team workflow के अनुसार ही use करें।

5. git reset --hard बिना समझे use करना

यह local changes discard कर सकता है।


Git Best Practices#

Small और meaningful commits करें

एक commit में logically related changes रखें।

Example:

Code
Add login form
Fix login validation
Update authentication error message

Clear commit messages लिखें

Commit देखकर future में समझ आना चाहिए कि change क्या था।

Branches का proper use करें

Feature और bug fixes के लिए अलग branches रखना useful हो सकता है।

Push करने से पहले changes check करें

Code
git status
git diff

फिर:

Code
git add .
git commit

Secrets commit न करें

.env और sensitive credentials को repository से बाहर रखें और project की secret-management practice follow करें।


Git का Mental Model#

Git को याद रखने का सबसे आसान तरीका:

Code
Working Directory
       ↓
   git add
       ↓
Staging Area
       ↓
  git commit
       ↓
Local Repository
       ↓
   git push
       ↓
Remote Repository

और remote से changes लाने के लिए:

Code
Remote Repository
       ↓
   git fetch
       ↓
Local Repository
       ↓
Integration
       ↓
Working Directory

Git Commands Cheat Sheet#

Commandकाम
git --versionGit version check करना
git configGit configuration manage करना
git initNew Git repository बनाना
git cloneRemote repository clone करना
git statusCurrent Git status देखना
git addChanges stage करना
git commitChanges commit करना
git logCommit history देखना
git diffChanges compare करना
git branchBranches देखना/manage करना
git switchBranch switch करना
git mergeBranches merge करना
git rebaseCommits को नई base पर replay करना
git remoteRemote repositories manage करना
git fetchRemote changes fetch करना
git pullRemote changes fetch/integrate करना
git pushLocal commits remote पर भेजना
git restoreFile/staging changes restore करना
git revertCommit को reverse करने वाला नया commit बनाना
git resetBranch/history position बदलना
git stashTemporary changes store करना
git tagCommit को version/name देना
git cherry-pickSpecific commit apply करना

Most Important Git Commands#

अगर आप beginner हैं, तो शुरुआत में इन commands पर focus करें:

Code
git init
git clone
git status
git add
git commit
git log
git diff
git branch
git switch
git merge
git pull
git push

इन commands को practically use करने के बाद Git का basic workflow काफी clear हो जाता है।


Git Daily Workflow Cheat Sheet#

एक normal feature पर काम करते समय:

Code
# Repository में जाएँ
cd my-project

# Current status देखें
git status

# Latest changes लें
git pull

# New feature branch बनाएँ
git switch -c feature/login

# Code में changes करें

# Changes check करें
git status
git diff

# Changes stage करें
git add .

# Commit करें
git commit -m "Add login feature"

# Remote पर push करें
git push -u origin feature/login

इसके बाद team के workflow के अनुसार Pull Request और code review हो सकता है।


Git सीखने के लिए Practice#

Beginner Practice

एक नया folder बनाएं:

Code
mkdir git-practice
cd git-practice
git init

एक file बनाएं:

Code
hello.txt

फिर:

Code
git status
git add hello.txt
git commit -m "Add hello file"

अब history देखें:

Code
git log --oneline

Intermediate Practice

एक branch बनाएं:

Code
git switch -c feature/about

एक नई file add करें:

Code
about.txt

फिर:

Code
git add .
git commit -m "Add about page"

अब main पर जाएँ:

Code
git switch main

और branch merge करें:

Code
git merge feature/about

फिर:

Code
git log --oneline

से history check करें।


Advanced Practice

एक simple project में:

  1. main branch बनाएं.
  2. feature/login branch बनाएं.
  3. Login feature develop करें.
  4. Multiple commits करें.
  5. Remote repository add करें.
  6. Feature branch push करें.
  7. Merge और rebase का difference observe करें.
  8. एक intentional merge conflict create करके resolve करें.
  9. git revert का practice करें.
  10. git stash का practice करें.

इस practice से सिर्फ commands याद नहीं होंगी, बल्कि Git workflow समझ आएगा।


Knowledge Check#

Beginner

  1. Git क्या है?
  2. Version Control क्या होता है?
  3. Repository क्या है?
  4. Working Directory क्या है?
  5. Staging Area क्या है?
  6. Commit क्या होता है?
  7. git status क्या करता है?
  8. git add और git commit में क्या difference है?

Intermediate

  1. Branch क्यों बनाई जाती है?
  2. git switch का use क्या है?
  3. git merge क्या करता है?
  4. Merge conflict क्यों होता है?
  5. git pull और git fetch में क्या difference है?
  6. Remote repository क्या होती है?
  7. .gitignore क्यों use किया जाता है?

Advanced

  1. Merge और rebase में क्या difference है?
  2. Rebase shared history पर risky क्यों हो सकता है?
  3. git revert और git reset में क्या difference है?
  4. git stash कब useful होता है?
  5. git cherry-pick कब use किया जा सकता है?
  6. Git workflow को team-based development में कैसे use करेंगे?

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

Git की पूरी basic journey को इस तरह याद रखें:

Code
Create / Clone
      ↓
Change
      ↓
Status
      ↓
Add
      ↓
Commit
      ↓
Branch
      ↓
Merge / Rebase
      ↓
Push
      ↓
Remote

और जब remote से latest code चाहिए:

Code
Fetch / Pull

सबसे important formula

Code
git status
    ↓
git add
    ↓
git commit
    ↓
git push

अगर यह basic workflow समझ आ गया, तो Git सीखने की strong foundation बन जाती है।


Summary#

Git एक distributed version control system है जो project के changes को track और manage करने में help करता है।

इस Git Cheat Sheet में हमने समझा:

  • Git और Version Control
  • Repository
  • Working Directory
  • Staging Area
  • Commit
  • Branch
  • Merge
  • Rebase
  • Remote
  • Fetch
  • Pull
  • Push
  • .gitignore
  • Stash
  • Tag
  • Cherry-pick
  • Revert
  • Reset
  • Common Git commands
  • Common Git errors
  • Git workflow
  • Practical exercises

Short में:

Code
Working Directory
        ↓
     git add
        ↓
 Staging Area
        ↓
   git commit
        ↓
 Local Repository
        ↓
    git push
        ↓
 Remote Repository

Git का goal सिर्फ commands याद करना नहीं है। आपको यह समझना है कि code change होने से लेकर commit और remote repository तक उसका पूरा workflow कैसे चलता है।