Feedback Form

Git & GitHub basics in hindi

Git & GitHub Basics in Hindi

आज के time में अगर आप Computer Science, IT, Skill, MCA, Diploma या किसी भी technical course के student हो, तो Git & GitHub समझना almost compulsory हो गया है। College exams से लेकर real-world projects और jobs तक, हर जगह version control का use होता है। इस article में हम Git & GitHub basics को बिल्कुल simple, classroom-style हिंदी में समझेंगे।

Git Introduction

Git एक Version Control System है। इसका main काम होता है किसी भी project के code में होने वाले changes को track करना। जब हम code लिखते हैं, तो हर बार change करने पर Git उस change का record रखता है।

आसान भाषा में कहें तो Git हमें यह सुविधा देता है कि हम अपने पुराने code पर वापस जा सकें, अलग-अलग versions बना सकें और बिना डर के experiment कर सकें।

Why Use Git

College students अक्सर एक ही file को बार-बार overwrite कर देते हैं, जिससे पुराना data lost हो जाता है। Git इस problem को solve करता है। Git हर change का history maintain करता है।

Git का use करने से teamwork आसान हो जाता है। Multiple students या developers एक ही project पर simultaneously काम कर सकते हैं, बिना एक-दूसरे का code खराब किए।

  • Code का complete history available रहता है
  • गलत change होने पर rollback possible होता है
  • Team collaboration आसान होता है
  • Exam practicals में version control concept clear रहता है

Git Installation

Git को use करने के लिए सबसे पहले उसे system में install करना पड़ता है। Windows, Linux और macOS — तीनों platforms के लिए Git available है।

Windows में Git install करने के बाद Git Bash नाम का terminal मिलता है, जिसमें हम commands run करते हैं। Exams में अक्सर Git Bash से जुड़े questions पूछे जाते हैं।

Git Repository

Repository को short में Repo भी कहा जाता है। Repository वो जगह होती है जहाँ आपका पूरा project और उसका version history store रहता है।

जब आप किसी folder को Git repository बनाते हो, तो Git उस folder के अंदर hidden रूप से एक .git directory create करता है, जिसमें सारी tracking information रहती है।

Git init Command

किसी normal folder को Git repository बनाने के लिए git init command का use किया जाता है। यह command उस folder में Git tracking शुरू कर देती है।

git init

Exam point of view से यह command बहुत important है, क्योंकि इससे Git project की शुरुआत होती है।

Git Status Command

git status command हमें यह बताती है कि repository की current condition क्या है। कौन सी files modified हैं, कौन सी new हैं और कौन सी staging area में हैं।

git status

Beginners के लिए यह command सबसे useful होती है, क्योंकि इससे confusion कम होता है और project clear दिखता है।

Git Add Command

Git में directly commit नहीं किया जाता। पहले file को staging area में add करना पड़ता है। इसके लिए git add command का use होता है।

git add filename

अगर सभी files को एक साथ staging area में add करना हो, तो dot (.) का use किया जाता है।

git add .

Git Commit Command

Commit का मतलब होता है current changes को permanently save करना। हर commit के साथ एक message लिखा जाता है, जिससे future में समझ आए कि उस time क्या change किया गया था।

git commit -m "Initial commit"

Exams में commit को अक्सर snapshot of project कहा जाता है, क्योंकि यह उस समय की condition को save कर लेता है।

Version Control Concept

Version Control का मतलब है project के अलग-अलग versions को manage करना। Git automatically versions create करता है, जिससे manual copy-paste की जरूरत नहीं पड़ती।

मान लो आपने project का पहला version बनाया, फिर उसमें change किया, फिर और change किया — Git हर step को याद रखता है।

Introduction to GitHub

GitHub एक online platform है जहाँ Git repositories को store किया जाता है। Git local system पर काम करता है, जबकि GitHub internet पर projects को host करता है।

GitHub का use करके हम अपना project दुनिया के साथ share कर सकते हैं, teachers को assignment दिखा सकते हैं और companies को अपना work demonstrate कर सकते हैं।

Git vs GitHub

Git GitHub
Version Control Tool Online Hosting Platform
Offline काम करता है Internet required होता है
Code track करता है Code share और collaborate करता है

यह difference exams में direct पूछा जाता है, इसलिए Git और GitHub को कभी confuse नहीं करना चाहिए।

GitHub Account Creation

GitHub use करने के लिए सबसे पहले account बनाना पड़ता है। इसमें username, email और password की जरूरत होती है। Students के लिए GitHub free version ही sufficient होता है।

एक बार account बनने के बाद आप unlimited public repositories बना सकते हो और अपने projects upload कर सकते हो।

Repository on GitHub

GitHub पर repository create करने का मतलब है online project space बनाना। यहाँ आपका पूरा code, commits और changes store रहते हैं।

College assignments और mini projects को GitHub repository में डालना एक professional habit मानी जाती है।

Git Clone Command

git clone command का use GitHub से किसी existing repository को अपने local system में download करने के लिए किया जाता है। जब कोई project पहले से GitHub पर available हो और आपको उस पर काम करना हो, तब clone किया जाता है।

Clone करने के बाद पूरा project, उसकी files और commit history आपके system में आ जाती है। Exam में यह पूछा जाता है कि clone और download में क्या difference है।

git clone repository-url

Git Push Command

Local system पर किए गए commits को GitHub repository पर भेजने के लिए git push command का use किया जाता है। जब तक push नहीं किया जाता, तब तक GitHub पर changes reflect नहीं होते।

College practicals में students अक्सर commit तो कर लेते हैं, लेकिन push करना भूल जाते हैं, जिससे GitHub पर code दिखाई नहीं देता।

git push origin main

Git Pull Command

git pull command GitHub से latest changes को local repository में लाने के लिए use होती है। जब team का कोई member नया code push करता है, तो बाकी members pull करके updated code ले सकते हैं।

Pull command actually दो काम एक साथ करती है — fetch और merge। Exam point of view से यह line बहुत important है।

git pull origin main

Git Branch Concept

Branch का मतलब होता है main project से अलग एक parallel line में काम करना। Default branch को आमतौर पर main या master कहा जाता है।

Branch का use इसलिए किया जाता है ताकि main code safe रहे और नया feature या experiment अलग branch में किया जा सके।

Create Branch in Git

नई branch बनाने के लिए git branch command का use किया जाता है। यह command केवल branch create करती है, switch नहीं करती।

git branch feature-branch

Branch switching के लिए अलग command use होती है, जो exams में भी पूछी जाती है।

Git Checkout Command

git checkout command का use एक branch से दूसरी branch में switch करने के लिए किया जाता है। इससे working directory उसी branch के code पर चली जाती है।

git checkout feature-branch

Modern Git versions में checkout की जगह git switch भी use किया जाता है, लेकिन exam syllabus में checkout ज्यादा common है।

Git Merge Command

जब किसी branch में काम complete हो जाता है, तब उसे main branch के साथ जोड़ने के लिए git merge command का use किया जाता है।

Merge process में Git automatically changes को combine करता है। अगर same line में conflict हो, तो उसे manually resolve करना पड़ता है।

git merge feature-branch

Merge Conflict

Merge conflict तब होता है जब same file की same line को दो branches में अलग-अलग तरीके से modify किया गया हो। Git decide नहीं कर पाता कि कौन सा change सही है।

Conflict resolve करना developer का काम होता है। Exams में अक्सर पूछा जाता है कि merge conflict क्या होता है।

Git Log Command

git log command repository की पूरी commit history दिखाती है। इसमें commit id, author, date और message दिखाई देता है।

Debugging और exam revision के लिए यह command बहुत useful मानी जाती है।

git log

Git Diff Command

git diff command changes को compare करने के लिए use होती है। यह बताती है कि last commit और current working file में क्या difference है।

इससे students को clear समझ आता है कि उन्होंने code में exactly क्या change किया है।

git diff

GitHub Workflow

GitHub workflow एक standard process होता है जिससे team efficiently काम करती है। इसमें code लिखना, commit करना, push करना और review शामिल होता है।

Exams में इसे steps में समझाने को कहा जाता है, इसलिए concept clarity जरूरी है।

  • Local system पर code लिखना
  • git add और git commit करना
  • git push से GitHub पर भेजना
  • Team द्वारा review और update

GitHub Collaboration

GitHub collaboration का मतलब है multiple users का एक ही repository पर काम करना। हर member अपना code push करता है और बाकी members pull करके changes लेते हैं।

College group projects में GitHub collaboration students को professional तरीका सिखाता है।

Pull Request Concept

Pull Request GitHub का एक important feature है। जब कोई contributor अपनी branch का code main branch में जोड़ना चाहता है, तो वह pull request create करता है।

Teacher या project leader pull request को review करके accept या reject कर सकता है। Exam में इसे code review process भी कहा जाता है।

.gitignore File

.gitignore file का use उन files को ignore करने के लिए किया जाता है जिन्हें repository में upload नहीं करना होता।

Example के लिए temporary files, logs और system files को gitignore में रखा जाता है।

node_modules/ *.log

Git & GitHub Exam Summary

Git & GitHub basics हर computer-related course का core topic बन चुका है। Commands, concepts और workflow को समझना exams और interviews दोनों के लिए जरूरी है।

अगर student Git और GitHub को practical तरीके से समझ लेता है, तो real-world projects और internships में उसे काफी advantage मिलता है।

FAQs

Git एक Version Control System है, जिसका उपयोग project के code में होने वाले changes को track करने के लिए किया जाता है। Git का उपयोग इसलिए किया जाता है ताकि code का history सुरक्षित रहे, गलती होने पर पुराने version पर वापस जाया जा सके और teamwork के दौरान code manage करना आसान हो।

GitHub एक online platform है जहाँ Git repositories को host किया जाता है। Git local system पर code track करता है, जबकि GitHub internet पर code को store, share और collaborate करने की सुविधा देता है। Exam में Git और GitHub का difference अक्सर पूछा जाता है।

Git Repository वह जगह होती है जहाँ project की सभी files और उनका पूरा version history store रहता है। Repository के अंदर .git folder होता है, जिसमें Git से जुड़ी सारी tracking information रहती है। यही repository GitHub पर भी upload की जाती है।

Git commit का मतलब होता है current changes को permanently save करना। Commit message इसलिए जरूरी होता है ताकि future में यह समझ आ सके कि उस commit में क्या बदलाव किया गया था। Exams में commit को project का snapshot भी कहा जाता है।

Git push command local commits को GitHub repository पर भेजने के लिए use होती है। Git pull command GitHub से latest changes को local system में लाने के लिए use होती है। Team projects में ये दोनों commands बहुत important होती हैं।

Git branch का उपयोग main code से अलग होकर काम करने के लिए किया जाता है। जब branch का काम complete हो जाता है, तब Git merge command से उसे main branch में जोड़ दिया जाता है। इससे main project safe रहता है और development smooth होता है।