Skip to Content

Git & GitHub — Cheatsheet

🔖

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

Initial Setup

গিট ইনস্টল করার পর প্রথমবার যে কনফিগারেশনগুলো করতে হয়।

Terminal
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

নতুন রিপোজিটরি তৈরি বা গিটহাব থেকে ক্লোন করার কমান্ডসমূহ।

Terminal
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

প্রতিদিনের কাজে সবচেয়ে বেশি ব্যবহৃত গিট কমান্ডগুলো।

Terminal
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

নতুন ব্রাঞ্চ তৈরি, ডিলিট এবং সুইচ করার প্রোফেশনাল কমান্ডসমূহ।

Terminal
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

বিভিন্ন ব্রাঞ্চের কোড এক জায়গায় করার প্রয়োজনীয় কমান্ডগুলো।

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

Stash

অর্ধেক করা কাজগুলো সাময়িকভাবে জমা রাখার সহজ কমান্ডসমূহ।

Terminal
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

তোমার কাজের পূর্ণাঙ্গ ইতিহাস দেখার বিভিন্ন উপায়।

Terminal
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

ভুলবশত করা কাজগুলো আগের অবস্থায় ফিরিয়ে নেওয়ার নিয়ম।

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

Tags

সফটওয়্যারের নির্দিষ্ট ভার্সন মার্ক করার জন্য ট্যাগ ব্যবহারের নিয়ম।

Terminal
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

অন্যের প্রোজেক্টে কন্ট্রিবিউট করার জন্য ফর্ক সিঙ্ক করার কমান্ড।

Terminal
# 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

লাইভ সাইটের ইমারজেন্সি সমস্যা সমাধানের পূর্ণাঙ্গ গাইড।

Terminal
# ১. 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-fix

Commit Guide

পেশাদার এবং অর্থবহ কমিট মেসেজ লেখার একটি সংক্ষিপ্ত ডিরেক্টরি।

Types

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

উদাহরণ

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

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 Fixes

জরুরি মুহূর্তে ভুল ফিক্স করার জন্য কিছু কমন সলিউশন।

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

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

Full Workflow

প্রতিদিনের কাজের একটি আদর্শ ফ্লো যা তোমার মুখস্থ রাখা উচিত।

সকালে

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

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

Terminal
git add . git commit -m "Descriptive message"

দিনের শেষে

Terminal
git push -u origin feature/your-task

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

Terminal
git switch main git pull git branch -d feature/your-task

Search Keywords: git commands, git aliases, undo commit, reset hard, revert commit, git tag, cheat sheet

Last updated on