Git & GitHub — Cheatsheet
সব important commands এক জায়গায়। Bookmark করো, print করো, দেওয়ালে লাগাও।
Initial 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 Start
নতুন রিপোজিটরি তৈরি বা গিটহাব থেকে ক্লোন করার কমান্ডসমূহ।
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 করোView 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 Actions
ভুলবশত করা কাজগুলো আগের অবস্থায় ফিরিয়ে নেওয়ার নিয়ম।
Commit করার আগে
git restore filename.txt # File-এর changes undo করো
git restore --staged filename.txt # Unstage করোreset --hardসাবধানে — changes permanently মুছে যায়।- Push করার পর
resetকরবে না —revertব্যবহার করো।
Tags
সফটওয়্যারের নির্দিষ্ট ভার্সন মার্ক করার জন্য ট্যাগ ব্যবহারের নিয়ম।
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 mainHotfix Workflow
লাইভ সাইটের ইমারজেন্সি সমস্যা সমাধানের পূর্ণাঙ্গ গাইড।
# ১. Production ব্রাঞ্চে যাও এবং লেটেস্ট কোড নামাও
git switch main
git pull
# ২. ইমারজেন্সি হটফিক্স ব্রাঞ্চ তৈরি করো
git switch -c hotfix/critical-bug-fix
# [বাগ ফিক্স করো...]
# ৩. ফিক্স সেভ (commit) করো
git add .
git commit -m "Fix critical bug"
# ৪. Main-এ ফিরে ফিক্সটি মার্জ করে লাইভ করো
git switch main
git merge hotfix/critical-bug-fix
git push
# ৫. (Optional) নতুন ভার্সন ট্যাগ করো
git tag -a v1.0.1 -m "Hotfix: critical bug"
git push origin v1.0.1
# ৬. Develop ব্রাঞ্চেও ფিক্সটি সিঙ্ক করো (অত্যন্ত জরুরি)
git switch develop
git merge hotfix/critical-bug-fix
git push
# ৭. কাজ শেষে লোকাল ব্রাঞ্চটি ক্লিনআপ করো
git branch -d hotfix/critical-bug-fixCommit 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 dependenciesNaming Guide
ব্রাঞ্চের নাম দেওয়ার প্রফেশনাল স্ট্যান্ডার্ডগুলো একনজরে দেখো।
feature/short-description → নতুন feature
fix/short-description → Bug fix
hotfix/short-description → Emergency live fix
docs/short-description → Documentation
chore/short-description → Cleanup, updatePanic Fixes
জরুরি মুহূর্তে ভুল ফিক্স করার জন্য কিছু কমন সলিউশন।
ভুল branch
“আমি ভুল branch-এ commit করেছি!“
git reset HEAD~1 # Commit undo করো
git switch correct-branch # সঠিক branch-এ যাও
git add .
git commit -m "Your message"Full Workflow
প্রতিদিনের কাজের একটি আদর্শ ফ্লো যা তোমার মুখস্থ রাখা উচিত।