Skip to Content

Git & GitHub — Cheatsheet

🔖

সব important commands এক জায়গায়। Bookmark করো, print করো, দেওয়ালে লাগাও।

Setup (একবার করলেই হয়)

git --version # Git installed কিনা check করো git config --global user.name "Your Name" # তোমার নাম set করো git config --global user.email "you@example.com" # তোমার email set করো git config --global init.defaultBranch main # Default branch নাম git config --list # সব config দেখো

Project শুরু করা

git init # নতুন repo শুরু করো git clone git@github.com:user/repo.git # GitHub থেকে clone করো git remote -v # Remote connections দেখো git remote add origin git@github.com:user/repo.git # Remote add করো git remote set-url origin git@github.com:user/repo.git # Remote URL change করো

Daily Workflow

git status # কী কী changed দেখো git add filename.txt # Specific file stage করো git add . # সব changes stage করো git restore --staged filename.txt # Stage থেকে বাদ দাও git commit -m "Your message here" # Commit করো git push # GitHub-এ upload করো git push -u origin main # প্রথমবার push (branch set করে) git pull # GitHub থেকে latest নামাও git fetch origin # Download করো, apply করো না

Branching

git branch # Local branches দেখো git branch -a # সব branches দেখো (remote সহ) git switch branch-name # Branch-এ যাও git switch -c feature/new-feature # নতুন branch বানাও এবং যাও git branch -d branch-name # Branch delete করো (merged) git branch -D branch-name # Branch force delete করো git push origin --delete branch-name # Remote branch delete করো git fetch --prune # Deleted remote branches clean করো

Merging

git merge branch-name # Branch merge করো git merge origin/main # Remote main merge করো git merge --abort # Merge cancel করো (conflict-এ)

Stash

git stash # Current changes সরিয়ে রাখো git stash pop # Stash ফিরিয়ে আনো git stash list # সব stash দেখো git stash apply stash@{1} # Specific stash apply করো git stash drop # Latest stash delete করো git stash clear # সব stash delete করো

History দেখা

git log # Full commit history git log --oneline # Short history git log --oneline --graph # Branch tree সহ history git log --author="Name" # নির্দিষ্ট কারো commits git log --since="2 weeks ago" # নির্দিষ্ট সময়ের commits git diff # Unstaged changes দেখো git diff --staged # Staged changes দেখো git show a1b2c3d # Specific commit দেখো

Undo করা

git restore filename.txt # File-এর changes undo করো git restore --staged filename.txt # Unstage করো
  • reset --hard সাবধানে — changes permanently মুছে যায়।
  • Push করার পর reset করবে না — revert ব্যবহার করো।

Tags (Version Marking)

git tag # সব tags দেখো git tag -a v1.0.0 -m "First release" # Annotated tag বানাও git push origin v1.0.0 # Tag GitHub-এ push করো git push origin --tags # সব tags push করো

Fork Workflow

# Fork clone করার পর git remote add upstream git@github.com:original/repo.git # Fork sync করো git fetch upstream git switch main git merge upstream/main git push origin main

Hotfix Workflow (Emergency)

git switch main git pull git switch -c hotfix/critical-bug-fix # fix করো git add . git commit -m "Fix critical bug" git switch main git merge hotfix/critical-bug-fix git push git tag -a v1.0.1 -m "Hotfix: critical bug" git push origin v1.0.1 git switch develop git merge hotfix/critical-bug-fix git push git branch -d hotfix/critical-bug-fix

Commit Message Guide

Types

Typeকখন
feat:নতুন feature
fix:Bug fix
docs:Documentation
style:Formatting (code logic change না)
refactor:Code restructure
chore:Dependency update, config change

উদাহরণ

feat: add price filter to product listing fix: resolve login redirect on Safari docs: update README with installation steps chore: update npm dependencies

Branch Naming Guide

feature/short-description → নতুন feature fix/short-description → Bug fix hotfix/short-description → Emergency live fix docs/short-description → Documentation chore/short-description → Cleanup, update

Panic Situations & Fixes

“আমি ভুল branch-এ commit করেছি!“

git reset HEAD~1 # Commit undo করো git switch correct-branch # সঠিক branch-এ যাও git add . git commit -m "Your message"

Complete Daily Workflow (মুখস্থ করো)

সকালে

git switch main git pull git switch -c feature/your-task

কাজের মাঝে (বারবার)

git add . git commit -m "Descriptive message"

দিনের শেষে

git push -u origin feature/your-task

কাজ শেষে (PR merge হওয়ার পর)

git switch main git pull git branch -d feature/your-task
Last updated on