🇳🇵  नेपाली र English — Mixed Learning Experience

Master Git &
GitHub

Version control सिक्नुस् — from zero to professional

Beginner देखि Team Collaboration सम्म — सबै कुरा एकै ठाउँमा

8Modules
50+Commands
30+Real Examples
🔥Interactive
c1 c2 c3 f1 f2 c4 main feature-a feature-b merge HEAD

Git भनेको के हो? What is Git?

सजिलो भाषामा बुझौं — Let's understand in simple terms

Before writing a single command, let's truly understand what problem Git solves.

😰 जीवन बिना Git

Git नभएको बेला के हुन्छ त?

Imagine you're writing a thesis or building an app. Without Git:

  • You save files as project_final.zip, project_final2.zip, project_FINAL_USE_THIS.zip 😭
  • You accidentally delete something and can't recover it
  • Two people edit the same file — total chaos!
  • You can't remember what changed 3 days ago
🌍 Real Life Example (नेपाली Context) मानौं तपाईं एउटा ecommerce website बनाइरहनु भएको छ। एउटा bug fix गर्दा नयाँ bug आयो। Git भएको भए ३ second मा पुरानो version मा फर्कन सकिन्थ्यो!
✅ Git ले गर्ने काम: Git is like a time machine + checkpoint system for your code. Every time you "commit", you take a snapshot. You can travel back to any snapshot, branch off into parallel universes of code, and merge them back together!
😱 Without Git project.zip project_v2.zip project_final.zip project_FINAL2.zip project_USE_THIS.zip Total Confusion! 😭 ✅ With Git Initial commit Add login page Fix cart bug Add payment v1.0 release 🎉 Clean History! ✅ ⏪ Go back to any point!

८ वटा Modules — Complete Path

सुरुदेखि अन्तसम्म — Complete beginner to pro
Module 01
Setup & Installation
Git install गर्ने र configure गर्ने
Install Git on Windows/Mac/Linux. Set your identity. Understand what happens behind the scenes.
Module 02
First Repo & Commits
पहिलो repository र commit बनाउने
git init, add, commit — the core loop. Understand the staging area. Write great commit messages.
Module 03
Branching & Merging
Branch बनाउने, merge गर्ने र conflict सुल्झाउने
Parallel development, merge strategies, conflict resolution. The most powerful part of Git!
Module 04
GitHub & Remotes
GitHub मा code राख्ने र sync गर्ने
Push, pull, clone. SSH setup. Connect your local work to the cloud. GitHub profile setup.
Module 05
Pull Requests & Collaboration
Team मा काम गर्ने तरिका — PR र Code Review
Fork, PR workflow, code review, merge strategies. How real teams ship features.
Module 06
Undoing & Advanced Git
गल्ती सुधार्ने — Stash, Reset, Rebase, Reflog
Stash, revert, reset, interactive rebase, cherry-pick. Recover from any mistake!
Module 07
Team Workflows
Professional team मा Git कसरी use गर्ने
Gitflow, GitHub Flow, conventional commits, CI/CD basics. Used by real companies!

Core Concepts — विस्तारमा बुझौं

प्रत्येक concept को What, Why र How — Real examples सहित

Git Setup

पहिलोपटक Git configure गर्दा के गर्ने?

After installing Git, you must tell it who you are. Every commit you make will be stamped with your name and email — like a signature on a document.

Why is this important? किन जरुरी छ? जब तपाईं GitHub मा काम गर्नुहुन्छ, team का सबैले देख्छन् "कसले यो change गर्यो।" तपाईंको identity बिना, commits anonymous हुन्छन् — real world मा यो acceptable छैन।
Real Life: Kathmandu startup scenario मान्नुस् तपाईं Daraz Nepal को developer हो। Bug report आयो — "cart क्रास हुँदैछ।" git log हेर्दा देखियो यो change राम् राम् ले ३ दिन अघि गरेको हो। Contact गर्न सकियो — Git ले गर्दा!
Pro Tip Use the same email as your GitHub account — otherwise your commits won't link to your profile and your contribution graph stays empty! 😢
Terminal
# Git version check — Git install भयो कि नाई? git --version # तपाईंको नाम set गर्नुस् (globally) git config --global user.name "Aarav Shrestha" # Email — GitHub email नै use गर्नुस्! git config --global user.email "aarav@example.com" # Default editor — VS Code राम्रो choice हो git config --global core.editor "code --wait" # सबै config हेर्नुस् git config --list
$ git config --global user.name "Aarav Shrestha" $ git config --global user.email "aarav@gmail.com" $ _ Identity Set!

The Three Stages

Git को तीन अवस्था — यो नबुझी Git बुझिँदैन!

This is the most important concept to understand. Git has THREE areas your files can be in:

  1. Working Directory — तपाईंले edit गर्ने ठाउँ
  2. Staging Area (Index) — Next commit मा के जाने भनी छान्ने ठाउँ
  3. Repository (.git) — Permanently saved history
Cinema Analogy / चलचित्र सादृश्य Working Directory = अभिनेताले rehearsal गर्ने ठाउँ
Staging Area = Director ले "action!" भन्नु अघिको setup
Commit = Final scene shoot भएर permanently record भयो!
Smart Staging Trick Use git add -p to stage changes line by line — perfect when one file has two unrelated changes. Very professional!
⚠️ Common Beginner Mistake धेरै beginners ले git add गरेपछि git commit नगरेको बिर्सन्छन्! After git add, you MUST git commit to save permanently. Closing the terminal doesn't save!
Working Directory app.js ✏️ style.css ✏️ git add Staging Area app.js ✅ style.css (not staged) git commit Repository (.git/) c1 c2 Your files (editable) Selected changes (ready to commit) Permanent history $ git status Changes to be committed: modified: app.js Untracked: style.css
Staging Commands
# Status check गर्नुस् — सधैं यहाँबाट सुरु git status # एउटा file stage गर्नुस् git add app.js # सबै changes stage गर्नुस् git add . # Specific changes छान्नुस् (line-by-line) git add -p # Commit — good message लेख्नुस्! git commit -m "feat: add login form validation" # Stage गरेको हेर्नुस् git diff --staged

🌿 Branching

Branch — parallel universe मा code लेख्ने तरिका!

A branch is like a parallel timeline for your code. You can experiment, add features, or fix bugs — without touching the main working code.

✅ किन Branch use गर्ने? मान्नुस् तपाईंको main website live छ। New feature थप्नु छ — directly main मा गर्यो भने production break हुन सक्छ। Branch बनाउनुस् → काम गर्नुस् → test गर्नुस् → तब मात्र merge गर्नुस्!
🌍 Team Example: Mero Kaam (Freelance Platform) Developer Sita ले payment feature मा काम गर्दैछिन् → branch: feature/payment
Developer Ram ले bug fix गर्दैछ → branch: hotfix/login-crash
दुवैले एकै बेला काम गर्न सक्छन् — main branch safe रहन्छ! 🎉
Branch Naming Convention feature/user-auth — new feature
fix/cart-bug — bug fix
hotfix/payment-crash — urgent fix
docs/api-guide — documentation
c1 c2 f1 f2 f3 h1 h2 M c3 HEAD main feature/payment hotfix/login-bug
Branching Commands
# Branches हेर्नुस् git branch # नयाँ branch बनाउनुस् र switch गर्नुस् git switch -c feature/payment # Branch switch गर्नुस् git switch main # Branch merge गर्नुस् (main मा भएर) git merge feature/payment # Merged branch delete गर्नुस् git branch -d feature/payment # Visual history हेर्नुस् — सबैभन्दा उपयोगी! git log --oneline --graph --all

Remote & GitHub

तपाईंको code internet मा राख्नुस् — सधैं safe!

A remote is a copy of your repository hosted on the internet (usually GitHub). Think of it as your code's backup + sharing hub + collaboration center.

✅ Remote किन use गर्ने? — तपाईंको laptop चोरियो → GitHub मा code safe छ!
— अर्को device मा काम गर्न सकिन्छ
— Team members सँग share गर्न सकिन्छ
— Portfolio को रूपमा देखाउन सकिन्छ (Jobs पाउनलाई!)
🌍 Real-world: Nepal ko Developer Scene धेरै Nepali developers ले GitHub profile नै CV को रूपमा use गर्छन्। "मेरो GitHub हेर्नुस्" भन्नुस् — contribution graph देखाउनुस् — job offer आउँछ! Remote मा code राख्नु = professional मा देखिनु।
SSH vs HTTPS SSH use गर्नुस् — हरपटक password type गर्नु पर्दैन!
SSH एकपटक setup गर्नुस्, सधैंको लागि काम गर्छ। Password = हरपटक झन्झट। SSH = smart choice!
Local your computer c1 c2 c3 GitHub github.com/user/repo git push git pull Teammate their laptop git clone → clone
Remote Commands
# Remote add गर्नुस् (एकपटक मात्र) git remote add origin git@github.com:username/repo.git # Remotes list हेर्नुस् git remote -v # पहिलोपटक push (-u ले tracking set गर्छ) git push -u origin main # त्यसपछि सधैं यति मात्र git push # Remote बाट changes ल्याउनुस् git pull # Existing repo clone गर्नुस् git clone git@github.com:username/repo.git

⏪ Undoing Things

गल्ती भयो? घबराउनु पर्दैन! Git ले सबै fix गर्न सकिन्छ।

This is where beginners panic, but Git actually makes recovery easy. The key is knowing which tool to use when.

⚠️ DANGER ZONE — सोचेर मात्र use गर्नुस्! git reset --hard ले तपाईंको uncommitted changes permanently delete गर्छ! Recovery impossible! Always double-check before using this.
✅ Safe Undo Decision Tree Push गरिसक्यो?git revert (safe, creates new commit)
Local मात्र छ?git reset --soft (commits undo, changes keep)
Trash गर्नु?git reset --hard (PERMANENT delete!)
🌍 Real Scenario: Production मा bug push भयो! भोलिपल्ट office पुग्दा boss ले भन्यो — "website down छ!"
git revert HEAD — एक command, production fixed! History पनि clean रहन्छ। Panic गर्नु पर्दैन!
Lifesaver: git reflog यसलाई "Git को Black Box" भन्नुस्! तपाईंले गरेको हरेक action यहाँ record हुन्छ — 90 दिनसम्म। Accidentally reset गर्यो? reflog ले ल्याइदिन्छ!
Undo Commands
# Staged file unstage गर्नुस् (commit हुँदैन) git restore --staged app.js # File को changes discard गर्नुस् ⚠️ git restore app.js # Last commit undo (changes staged रहन्छन्) git reset --soft HEAD~1 # Last commit undo (changes unstaged रहन्छन्) git reset --mixed HEAD~1 # SAFE: Revert a commit (history safe रहन्छ) git revert abc1234 # LIFESAVER: All actions history हेर्नुस् git reflog # Stash: कामलाई temporarily save गर्नुस् git stash git stash pop # वापस ल्याउनुस् git stash list # list हेर्नुस्
Reset Types Comparison c1 c2 c3 HEAD reset HEAD~1 --soft: safe --mixed: unstage --hard: ⚠️ delete

🤝 Pull Requests

Real team collaboration को core — PR बिना professional team काम गर्दैन

A Pull Request (PR) is a formal proposal to merge your code changes into the main codebase. It's where code review happens — teammates check your work before it goes live.

✅ PR system किन use गर्ने? एकजनाले directly main मा push गर्यो → bug आयो → production down! PR system ले यो prevent गर्छ। अर्कोले review गर्छन् → approve गरेपछि मात्र merge हुन्छ → team को code quality high हुन्छ!
🌍 PR ko Real Flow: Leapfrog Nepal Style मान्नुस् तपाईं Kathmandu को startup मा intern हो:
1. Senior ले task दिन्छ: "User profile page बनाऊ"
2. तपाईंले branch बनाउनुभयो, code लेख्नुभयो
3. PR open गर्नुभयो → Senior ले review गर्छन्
4. "Variable name change गर" → तपाईंले fix गर्नुभयो
5. "LGTM! Approved" → Merge! तपाईंको code live भयो! 🎉
Good PR Description Template ## What changed?
## Why?
## Screenshots
## Testing done
Closes #42
1 Fork / Branch बनाउनुस् 2 Code लेख्नुस् र Commit गर्नुस् 3 GitHub मा Push गर्नुस् 4 Pull Request Open गर्नुस् 5 Code Review → Merge! 🎉 Your code is now in production!
PR Workflow
# Step 1: Branch बनाउनुस् git switch -c feature/user-profile # Step 2: Changes commit गर्नुस् git add . git commit -m "feat: add user profile page" # Step 3: GitHub मा push गर्नुस् git push -u origin feature/user-profile # Step 4: GitHub website मा जानुस् # "Compare & pull request" button click गर्नुस् # Title, description लेख्नुस् → "Create PR" # Review feedback आएपछि fix गरेर: git add . git commit -m "fix: address review comments" git push # PR automatically update हुन्छ!

Professional Git Workflow

Real company मा कसरी काम हुन्छ — step-by-step

Click each step to learn more. यो workflow most Nepali IT companies ले follow गर्छन्!

01
📋 Task लिनुस् र Branch बनाउनुस्
Jira/Trello बाट task pick गर्नुस् → feature branch बनाउनुस्
Always start fresh from the latest main branch.
git switch main git pull # Latest code ल्याउनुस् पहिले! git switch -c feature/JIRA-123-user-auth
Tip Branch name मा ticket number राख्नुस् (JIRA-123) — team को लागि track गर्न सजिलो हुन्छ!
02
💻 Code लेख्नुस् — Regular Commits
Conventional commits format follow गर्नुस्
Small, focused commits. Each commit = one logical change.
# काम गर्नुस्... फेरि commit गर्नुस् git add . git commit -m "feat: add JWT token generation" git commit -m "test: add auth unit tests" git commit -m "docs: update API documentation"
Conventional Commit Types feat: / fix: / docs: / test: / refactor: / chore:
03
🔄 Main branch update लिनुस् (sync)
Teammates ले main मा changes गरेको हुनसक्छ — sync गर्नुस्
Avoid big merge conflicts by syncing frequently.
git fetch origin git rebase origin/main # Conflict आयो भने: fix → git add → git rebase --continue
🌍 Why this matters ३ हप्तापछि merge गर्यो भने hundreds of conflicts आउन सक्छन्। Daily sync गर्यो भने max 2-3 conflicts — manageable!
04
🚀 Push र PR Open गर्नुस्
GitHub मा push गरेर Pull Request open गर्नुस्
Write a clear description. Link the issue. Add screenshots if UI changed.
git push -u origin feature/JIRA-123-user-auth # GitHub ले automatically PR बनाउने suggestion दिन्छ!
05
✅ Review → Fix → Merge!
Teammate ले review गर्छन् → feedback address गर्नुस् → merge!
Respond to all comments. Be open to feedback — it makes you better!
Code Review Etiquette / शिष्टाचार — Suggestions दिनुस्, आदेश नदिनुस् ("Consider using X" not "Use X")
— Code criticize गर्नुस्, person लाई नगर्नुस्
— छिटो review गर्नुस् — 24 hours भित्र
— Nitpicks clearly label गर्नुस् (nit: small thing)
Nepal मा "LGTM" = "Looks Good To Me" = approve!
06
🧹 Cleanup गर्नुस्
Merged branch delete गर्नुस् — repo clean राख्नुस्
A clean repo is a happy repo. Delete merged branches immediately.
git switch main git pull # Merged changes ल्याउनुस् git branch -d feature/JIRA-123-user-auth # GitHub मा पनि delete — PR page मा "Delete branch" button

Tips, Tricks & Gotchas

अनुभवीहरूले सिकाउने कुराहरू — Beginners ले गर्ने common mistakes
Never commit secrets!
API keys, passwords कहिल्यै commit नगर्नुस्
एकपटक GitHub मा push भयो भने — bot ले 30 seconds भित्र scan गरिसक्छ। .env file को लागि .gitignore use गर्नुस्। Already committed? Key तुरुन्त rotate गर्नुस्!
Write meaningful commits
राम्रो commit message = भविष्यको उपहार
"fix" or "asdf" type commit messages ले team लाई confuse गर्छ। 6 months later आफैलाई थाहा हुँदैन के गरेको थियो! "feat: add OTP verification for login" — यस्तो लेख्नुस्।
Branch for everything
सानो change को लागि पनि branch बनाउनुस्
Even a typo fix deserves its own branch. Branches are free and instant in Git! यो habit बनाउनुस् — team मा काम गर्दा essential छ।
Always pull before push
Push गर्नु अघि pull गर्नुस् — conflicts avoid
Teammates ले पनि same branch मा काम गरिरहेको हुनसक्छ। git pull → fix conflicts locally → then push. यो ignore गर्यो भने "rejected" error आउँछ!
Use .gitignore early
Project सुरुमै .gitignore बनाउनुस्
node_modules, .env, build files — कहिल्यै commit नगर्नुस्। gitignore.io website मा जानुस् → language/framework type गर्नुस् → ready made .gitignore copy गर्नुस्!
git status is your friend
हर command अघि git status हेर्नुस्
Beginners ko most common mistake: not checking status. Before EVERY commit, run git status. It shows exactly what's staged, what's not, and what's untracked. 30 seconds को habit!
Tag your releases
Releases लाई tag गर्नुस् — v1.0.0 style
Production मा deploy गर्दा tag लगाउनुस्। Bug आयो भने "v1.2.0 deploy गरेपछि आयो" भन्न सकिन्छ। Semantic versioning: MAJOR.MINOR.PATCH
Git aliases save time
Common commands लाई shortcut बनाउनुस्
git config --global alias.st status git config --global alias.co checkout अब git st र git co use गर्न सकिन्छ!

Command Cheat Sheet

Click to copy! सबैभन्दा important commands — एकै ठाउँमा

Setup & Init

git initNew repo initialize
git clone <url>Remote repo copy
git config --global user.nameIdentity set
git config --listAll config हेर्नुस्

Staging & Committing

git statusChanges हेर्नुस्
git add .सबै stage गर्नुस्
git add -pSelective staging
git commit -m "msg"Commit गर्नुस्
git commit --amendLast commit edit
git diff --stagedStaged changes हेर्नुस्

Branching

git branchBranches list
git switch -c <name>Create + switch
git switch mainBranch switch
git merge <branch>Merge गर्नुस्
git branch -d <name>Branch delete
git log --oneline --graphVisual history

Remote

git remote -vRemotes list
git push -u origin mainFirst push
git pushPush changes
git pullPull changes
git fetch originFetch (safe)

Undo

git restore --stagedUnstage
git restore <file>Discard changes ⚠️
git revert HEADSafe undo commit
git reset --soft HEAD~1Undo commit, keep
git stashSave WIP
git reflogAll history 🆘

Try Commands Simulator

Common commands try गर्नुस् — result हेर्नुस्
git-simulator — ~/my-project
$ git status
On branch main
nothing to commit, working tree clean ✅
$

Try: git init · git status · git log · git branch · git help

Quick Quiz

तपाईंले कति सिक्नुभयो? — Test your knowledge!
Question 1/8
✅ Copied!