Back to Blog
গিট ও গিটহাব#Git#GitHub#CWS#codewithshohag

বাংলায় Git এবং GitHub | পার্ট-৩

Code with ShohagCode with Shohag
৪ জুন, ২০২৬ 190 বার পড়া 6 মিনিট পড়া
শেয়ার করুন:

এই পর্বে Local Git Repository-কে GitHub Repository-এর সাথে কীভাবে connect করতে হয় এবং প্রথমবার GitHub-এ code push করতে হয় তা ধাপে ধাপে দেখানো হয়েছে। পাশাপাশি origin, main, remote, এবং push এর মতো গুরুত্বপূর্ণ Git concept সহজ ভাষায় ব্যাখ্যা করা হয়েছে, যাতে beginner-রা সহজেই তাদের local project GitHub-এ publish করতে পারে।

বাংলায় Git এবং GitHub | পার্ট-৩

Local Repository আর GitHub Repository Connect করা


Part 1-এ আমরা দেখেছিলাম Git কী এবং GitHub কী।

Part 2-এ আমরা শিখেছিলাম:

  • Git install করা

  • Local repository তৈরি করা

  • File add করা

  • Commit করা

  • Commit history দেখা

আজকের part-এ আমরা শিখবো:

✅ GitHub-এ repository তৈরি করা

✅ Local repository-এর সাথে GitHub repository connect করা

✅ প্রথমবার GitHub-এ code push করা

origin, main এবং push এর অর্থ বোঝা

✅ পরবর্তীতে নতুন commit GitHub-এ পাঠানো

অর্থাৎ আজকে তোমার project শুধু computer-এর ভিতরে থাকবে না, GitHub-এও চলে যাবে।


শুরু করার আগে কী কী লাগবে?

এই tutorial follow করার জন্য তোমার তিনটি জিনিস লাগবে:

  • একটি GitHub account

  • Computer-এ Git install করা থাকতে হবে

  • একটি local Git repository থাকতে হবে

Part 2-এ আমরা যে project তৈরি করেছিলাম:

my-first-git-project

আজকে আমরা সেই project-টাই GitHub-এ upload করবো।


Local Repository এবং Remote Repository

GitHub-এ code push করার আগে এই concept দুটি পরিষ্কার হওয়া জরুরি।

Local Repository

তোমার নিজের computer-এ থাকা Git project।

Remote Repository

Internet-এ থাকা Git repository।

GitHub-এর repository-কে সাধারণত Remote Repository বলা হয়।

সহজভাবে:

Local Repository = তোমার computer-এর project

Remote Repository = GitHub-এ থাকা project

তুমি local repository-তে কাজ করবে, তারপর সেই কাজ GitHub-এ পাঠাবে।

এই পাঠানোর প্রক্রিয়াকে বলা হয়:

push


একটি Real-Life Example

ধরো তুমি একটি university project তৈরি করছো।

তোমার laptop-এর project folder হলো Local Repository।

আর GitHub-এ upload করা version হলো Remote Repository।

যদি laptop নষ্ট হয়ে যায়, তবুও GitHub-এ project নিরাপদ থাকবে।

আবার অন্য computer থেকেও project access করা যাবে।

এই কারণেই GitHub ব্যবহার করা হয়।


GitHub-এ নতুন Repository তৈরি করা

প্রথমে GitHub website-এ login করো।

তারপর উপরের ডান পাশে থাকা New Repository button-এ click করো।

Repository-এর নাম দাও:

my-first-git-project

Description দিতে চাইলে দিতে পারো।

তারপর Public অথবা Private নির্বাচন করো।

Public Repository

যে কেউ repository দেখতে পারবে।

Private Repository

শুধু তুমি এবং যাদের access দেবে তারাই দেখতে পারবে।


গুরুত্বপূর্ণ বিষয়

যেহেতু আমাদের project আগে থেকেই local repository হিসেবে আছে, তাই repository create করার সময় নিচের option-গুলো select করবে না:

  • Add a README file

  • Add .gitignore

  • Choose a license

কারণ এগুলো select করলে GitHub একটি initial commit তৈরি করবে।

আর local repository-তেও commit থাকলে পরবর্তীতে history mismatch বা merge conflict-এর সম্ভাবনা তৈরি হতে পারে।

Beginner হিসেবে empty repository তৈরি করাই সবচেয়ে সহজ।

এরপর click করো:

Create Repository


Repository Create করার পর কী দেখাবে?

Repository create হওয়ার পরে GitHub তোমাকে কিছু command দেখাবে।

যেমন:

git remote add origin ...
git branch -M main
git push -u origin main

ভয় পাওয়ার কিছু নেই।

এই part-এর বাকি অংশে আমরা প্রতিটি command-এর কাজ বুঝবো।


Local Project Folder-এ যাওয়া

এখন Git Bash অথবা Terminal open করো।

তারপর project folder-এ যাও।

cd Desktop
cd my-first-git-project

এখন নিশ্চিত হও যে তুমি repository-এর ভিতরে আছো।

git status

যদি output পাও, তাহলে সব ঠিক আছে।

যদি দেখায়:

not a git repository

তাহলে বুঝতে হবে তুমি ভুল folder-এ আছো।

Git-এর ক্ষেত্রে সঠিক folder-এ থাকা খুবই গুরুত্বপূর্ণ।


Commit আছে কিনা Check করা

GitHub-এ push করার আগে local repository-তে অন্তত একটি commit থাকতে হবে।

Check করার জন্য:

git log --oneline

যদি commit history দেখতে পাও, তাহলে সব ঠিক আছে।

যদি কোনো commit না থাকে:

git add .
git commit -m "first commit"

commit ছাড়া push করার মতো কোনো history Git-এর কাছে থাকবে না।


Branch কী?

এখন একটি নতুন শব্দ আসবে:

Branch

Branch হলো project-এর আলাদা development line।

Beginner হিসেবে এখন শুধু এটুকু মনে রাখো:

Main branch হলো project-এর প্রধান version।

আগে Git-এর default branch অনেক সময়:

master

হতো।

বর্তমানে বেশিরভাগ project-এ default branch:

main

ব্যবহার করা হয়।


Branch-এর নাম Main করা

যদি তোমার branch-এর নাম master বা অন্য কিছু হয়, তাহলে:

git branch -M main

এখানে:

  • git branch → branch related command

  • -M → rename করার option

  • main → নতুন branch name

এটি current branch-এর নাম main করে দেয়।

যদি branch আগে থেকেই main হয়, তাহলে এই command চালানোর দরকার নেই।


Remote Add করা

এখন local repository-এর সাথে GitHub repository connect করতে হবে।

GitHub repository-এর URL দেখতে এমন হবে:

https://github.com/username/my-first-git-project.git

তোমার repository-এর URL copy করো।

তারপর command চালাও:

git remote add origin https://github.com/username/my-first-git-project.git

এই Command কী করে?

এখানে:

git remote add

মানে নতুন remote connection যোগ করা।

origin

হলো remote repository-এর nickname।

আর URL হলো GitHub repository-এর address।

অর্থাৎ আমরা Git-কে বলছি:

"এই local project-এর online version এই GitHub repository-তে আছে।"


origin কী?

অনেক beginner origin দেখে confuse হয়ে যায়।

আসলে এটি শুধু একটি nickname।

Full URL বারবার লেখার পরিবর্তে Git ছোট একটি নাম ব্যবহার করে।

যেমন:

origin

পরে আমরা URL না লিখে শুধু origin ব্যবহার করতে পারি।


Remote Add হয়েছে কিনা Check করা

Check করার জন্য:

git remote -v

Output এমন হতে পারে:

origin https://github.com/username/my-first-git-project.git (fetch)

origin https://github.com/username/my-first-git-project.git (push)

এটি দেখালে connection সফলভাবে তৈরি হয়েছে।


প্রথমবার GitHub-এ Push করা

এখন local project GitHub-এ পাঠানোর সময়।

git push -u origin main

এখানে:

  • git push → GitHub-এ commit পাঠানো

  • origin → remote repository

  • main → main branch

  • -u → upstream connection save করা

অর্থাৎ local main branch GitHub-এর main branch-এ upload হবে।


Push করার সময় Login চাইতে পারে

প্রথমবার push করার সময় GitHub authentication চাইতে পারে।

অনেক ক্ষেত্রে browser-based sign-in window খুলবে।

কখনো Personal Access Token (PAT) ব্যবহার করতে হতে পারে।

GitHub এখন সাধারণ account password ব্যবহার করে push করার সুবিধা দেয় না।

তাই browser login method beginner-দের জন্য সবচেয়ে সহজ।


GitHub-এ Check করা

Push সফল হলে GitHub repository page refresh করো।

এখন repository-এর ভিতরে তোমার file-গুলো দেখতে পাবে।

যেমন:

index.html

Commit message-ও দেখতে পাবে।

অর্থাৎ তোমার code সফলভাবে GitHub-এ upload হয়েছে।

অভিনন্দন!

এখন project শুধু তোমার computer-এ সীমাবদ্ধ নয়।


Full Command Flow

আজকের পুরো process:

git status

git log --oneline

git branch -M main

git remote add origin https://github.com/username/my-first-git-project.git

git remote -v

git push -u origin main

পরে নতুন Change করলে কী হবে?

ধরো তুমি:

index.html

file edit করলে।

Workflow হবে:

git add .

git commit -m "update homepage"

git push

প্রথমবার upstream set করার পরে আর:

git push -u origin main

লিখতে হবে না।

শুধু:

git push

হলেই চলবে।


git add, git commit এবং git push

এই তিনটি command-এর পার্থক্য বুঝে রাখা খুব গুরুত্বপূর্ণ।

git add

Change-গুলো commit-এর জন্য প্রস্তুত করে।

git commit

Change-গুলো local history-তে save করে।

git push

Saved commit GitHub-এ পাঠায়।


Real-Life Example

ধরো তুমি Facebook-এ একটি post লিখছো।

git add

= Draft প্রস্তুত করা

git commit

= Draft save করা

git push

= Post publish করা

Draft save করলেই যেমন post public হয় না,

তেমনি commit করলেই code GitHub-এ চলে যায় না।

GitHub-এ পাঠাতে হলে push করতে হবে।


Common Mistakes

১. GitHub Repository Create করার সময় README Add করা

Local repository আগে থেকেই থাকলে beginner হিসেবে empty repository create করাই সবচেয়ে নিরাপদ।


২. ভুল URL ব্যবহার করা

Remote add করার সময় ভুল URL দিলে push কাজ করবে না।

তাই URL GitHub repository page থেকে copy করো।


৩. Commit না করে Push করা

ভুল Flow:

Edit → Push

সঠিক Flow:

Edit → Add → Commit → Push

৪. ভুল Folder-এ Command চালানো

Check করতে পারো:

git status

অথবা

pwd

৫. main এবং master Confusion

এই সমস্যা এড়াতে:

git branch -M main

ব্যবহার করা যায়।


যদি Remote আগে থেকেই Add করা থাকে?

Git দেখাতে পারে:

remote origin already exists

এর মানে origin আগে থেকেই আছে।

Check করো:

git remote -v

যদি ভুল URL থাকে:

git remote remove origin

তারপর আবার:

git remote add origin https://github.com/username/repository-name.git

আজকের গুরুত্বপূর্ণ Command

git remote add origin URL

Local repository-কে GitHub-এর সাথে connect করার জন্য।

git remote -v

Remote connection check করার জন্য।

git branch -M main

Branch-এর নাম main করার জন্য।

git push -u origin main

প্রথমবার GitHub-এ push করার জন্য।

git push

পরবর্তীতে নতুন commit GitHub-এ পাঠানোর জন্য।


ছোট করে মনে রাখার নিয়ম


শেষ কথা

আজকে আমরা শিখলাম:

  • GitHub-এ repository তৈরি করা

  • Local repository-এর সাথে GitHub repository connect করা

  • Remote URL add করা

  • origin কী

  • main branch কী

  • প্রথমবার GitHub-এ code push করা

  • পরবর্তীতে নতুন commit GitHub-এ পাঠানো

এই part-এর সবচেয়ে গুরুত্বপূর্ণ দুইটি command হলো:

git remote add origin URL

এবং

git push -u origin main

একটি GitHub-এর সাথে connection তৈরি করে, আর অন্যটি প্রথমবার code GitHub-এ upload করে।

শুরুতে GitHub-এ push করা একটু জটিল মনে হতে পারে। কিন্তু কয়েকবার practice করলে এটি একদম স্বাভাবিক workflow হয়ে যাবে।

পরের part-এ আমরা দেখবো:

  • GitHub থেকে project clone করা

  • git pull কী

  • Remote repository-এর update local computer-এ আনা

  • অন্য developer-এর change নিজের project-এ sync করা

মন্তব্যসমূহ (0)

মন্তব্য করতে লগইন করুন

Login to Comment