Loading...
Loading...
Git ek distributed version control system hai — iska matlab aap apni files ke har change ko track kar sakte ho, purani version pe wapas ja sakte ho, aur team ke saath collaborate kar sakte ho bina kisi conflict ke.
Without Git:
project_v1.zip
project_v2.zip
project_FINAL.zip
project_FINAL_REAL.zip ← sab log yahi karte hain!
With Git:
git log → poori history, kab kya badla sab pata
# Windows
# git-scm.com se installer download karo
# macOS
brew install git
# Linux (Ubuntu/Debian)
sudo apt install git
# Verify
git --version # git version 2.43.0
git config --global user.name "Rahul Kumar"
git config --global user.email "rahul@email.com"
git config --global core.editor "code --wait" # VS Code
git config --list # verify
Working Directory → Staging Area (Index) → Local Repo → Remote (GitHub)
(edit files) (git add) (git commit) (git push)
# Method 1: Naya project
mkdir my-project
cd my-project
git init # .git folder create hoga
# Method 2: GitHub se clone karna
git clone https://github.com/username/repo-name.git
cd repo-name
# 1. Status check karo
git status
# 2. Changes stage karo
git add filename.txt # specific file
git add src/ # folder
git add . # sab files
# 3. Commit karo
git commit -m "Add login functionality"
# Shortcut: add + commit ek saath (already tracked files ke liye)
git commit -am "Fix bug in login form"
# 4. Remote pe push karo
git push origin main
# 5. Latest changes pull karo
git pull origin main
git log # full history
git log --oneline # compact view
git log --oneline --graph # visual branch graph
git diff # unstaged changes
git diff --staged # staged changes
git show abc1234 # specific commit details
# Branch list
git branch # local branches
git branch -a # all (local + remote)
# New branch banana
git branch feature/login
git checkout feature/login
# Shortcut (create + switch)
git checkout -b feature/login
# OR (modern way)
git switch -c feature/login
# Main pe wapas aana
git checkout main
git switch main
# Branch merge karna
git checkout main
git merge feature/login
# Branch delete karna
git branch -d feature/login # safe delete
git branch -D feature/login # force delete
main → production code (always working)
develop → integration branch
feature/xyz → new features
hotfix/bug → urgent fixes
release/v2.0 → release preparation
# Remote connection dekhna
git remote -v
# Remote add karna
git remote add origin https://github.com/user/repo.git
# Push karna
git push origin main
git push origin feature/login
# First push (tracking set karna)
git push -u origin main # -u = set upstream
# Pull (fetch + merge)
git pull origin main
# Fetch only (merge nahi)
git fetch origin
git diff main origin/main # differences dekhna
# .gitignore file banao project root mein
touch .gitignore
# .gitignore example
node_modules/
.env
.env.local
dist/
build/
*.log
.DS_Store
*.pyc
__pycache__/
.idea/
.vscode/settings.json
# Last commit ke baad ki changes discard (unstaged)
git restore filename.txt # specific file
git restore . # sab
# Staged changes unstage karna
git restore --staged filename.txt
# Last commit undo (changes rakhna)
git reset --soft HEAD~1
# Last commit undo (changes unstaged)
git reset HEAD~1
# Last commit undo (sab kuch delete — CAREFUL!)
git reset --hard HEAD~1
# Public commit revert karna (history safe)
git revert abc1234
# Kisi purani state pe jaana temporarily
git stash # changes save karo
git stash pop # wapas laao
git stash list # sab stashes dekhna
git merge feature/login
# CONFLICT — same file mein different changes
# File khologe toh dikhega:
<<<<<<< HEAD
const title = "WohoTech";
=======
const title = "WohoTech Platform";
>>>>>>> feature/login
# Fix karo manually (choose ek ya combine karo)
const title = "WohoTech Platform"; # decision liya
# Phir
git add conflicted-file.js
git commit -m "Resolve merge conflict in title"
# 1. Fork karo (GitHub pe — someone else's repo)
# 2. Clone karo
git clone https://github.com/yourname/repo.git
# 3. Feature branch banao
git checkout -b fix/typo-in-readme
# 4. Changes karo + commit
git add README.md
git commit -m "Fix typo in installation section"
# 5. Push karo
git push origin fix/typo-in-readme
# 6. GitHub pe jaao → "Compare & pull request" click karo
# 7. Title + description likho
# 8. Submit karo → wait for review
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.lg "log --oneline --graph --all"
# Use karo
git st # = git status
git lg # = beautiful log
| Command | Kaam |
|---|---|
| git init | New repo banana |
| git clone URL | Remote repo copy karna |
| git add . | Sab changes stage karna |
| git commit -m "msg" | Changes save karna |
| git push | Remote pe upload |
| git pull | Remote se download + merge |
| git branch | Branches dekhna |
| git checkout -b name | New branch banana + switch |
| git merge branch | Branch merge karna |
| git log --oneline | History dekhna |
| git status | Current state |
| git stash | Changes temporarily save |
| git reset --soft HEAD~1 | Last commit undo |
Git ek local version control tool hai jo aapke computer pe kaam karta hai. GitHub ek cloud platform hai jahan aap apna Git repository online store aur share kar sakte hain.
git fetch — remote changes download karta hai but merge nahi karta. git pull — fetch + merge dono karta hai (git fetch + git merge).
git reset --soft HEAD~1 (changes staged rakhta hai), git reset --mixed HEAD~1 (changes unstaged), git reset --hard HEAD~1 (changes delete — careful!)
JavaScript Complete Guide — Beginner to Advanced (2026)
40 min · Beginner
DatabaseSQL Complete Guide — Database Queries for B.Tech & Placements (2026)
30 min · Intermediate
PythonPython for Beginners: 15-Day Complete Learning Plan
15 min · Beginner
ReactReact Hooks Explained: useState, useEffect, useContext & More
14 min · Intermediate
DSAData Structures and Algorithms: Full Fundamentals + Interview Prep
35 min · Intermediate
JavaTop 50 Java Interview Questions — B.Tech Placements 2026
18 min · Advanced
Your feedback helps us improve notes and tutorials.