← Back to Git Course | Chapter 10: Tools & Internals | Lesson 8 of 8

Git Glossary

एक Git glossary Git में नए words के लिए एक picture dictionary जैसी है, जैसे working folder, staging area और commit, ताकि आपको पता हो लोगों का मतलब क्या है।

Working Directory और Staging Area

working directory वे actual files हैं disk पर जिन्हें आप directly edit करते हैं, जबकि staging area (जिसे index भी कहते हैं) एक अलग holding zone है जहाँ आप exactly वे changes रखते हैं जो आप अपनी अगली commit में चाहते हैं। git add चलाना एक change को working directory से staging area में move करता है, और सिर्फ staged changes ही git commit चलाने पर शामिल होते हैं।

उदाहरण: Working Directory and Staging Area

bash
git add file.txt
git status

HEAD और Detached HEAD

HEAD एक pointer है जो भी commit आपने इस समय checkout की है उसकी ओर, और यह आमतौर पर सीधे एक commit के बजाय एक branch name की ओर point करता है, इसलिए commit करना HEAD और branch दोनों को साथ आगे move करता है। एक branch के बजाय एक specific commit hash checkout करना आपको detached HEAD state में डाल देता है, जहाँ नई commits किसी branch से attached नहीं होतीं और switch away करते ही खो सकती हैं जब तक आप उन्हें save करने के लिए एक branch न बनाएँ।

उदाहरण: HEAD and Detached HEAD

bash
git checkout a1b2c3d
# HEAD is now detached, pointing directly at a1b2c3d

Upstream और Tracking Branches

एक upstream branch वह remote branch है जिससे push और pull करने के लिए एक local branch default रूप से configured है, या तो clone time पर या explicitly git branch --set-upstream-to से set किया गया। एक बार set हो जाने पर, बिना arguments के plain git push और git pull को exactly पता होता है कि किस remote branch से बात करनी है, और Git आपको बता सकता है कि आपकी local branch इससे कितनी commits आगे या पीछे है।

उदाहरण: Upstream and Tracking Branches

bash
git branch --set-upstream-to=origin/main main
git push
git pull

Fast-Forward बनाम Merge Commit

एक fast-forward merge तब होता है जब target branch के diverge होने के बाद से कोई नई commits न हों, इसलिए Git बस branch pointer को incoming branch से match करने के लिए आगे move कर देता है बिना कोई नई commit बनाए। एक merge commit तब होता है जब दोनों branches अपनी नई commits के साथ diverge हो चुकी हों, इसलिए Git histories को वापस जोड़ने के लिए दो parents वाली एक नई commit बनाता है, log graph में एक fork-and-rejoin shape की तरह visible।

उदाहरण: Fast-Forward vs Merge Commit

bash
git merge feature-x
# fast-forward if main has no new commits, else a merge commit

Commit Hash और Ancestors

हर commit एक SHA-1 hash से identified है जो इसके content, parent commit, author, और message से compute किया गया है, यही वजह है कि किसी commit के बारे में कुछ भी बदलना एक अलग hash produce करता है। एक ancestor commit कोई भी ऐसी commit है जो एक दी गई commit से parent links को पीछे follow करके reachable है, और Git के HEAD~1 या HEAD~3 जैसे relative references उस ancestor chain में एक fixed संख्या में steps चलते हैं।

उदाहरण: Commit Hash and Ancestors

bash
git log --oneline
git log a1b2c3d --oneline
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. working directory और staging area को mix up करना, और यह मान लेना कि changes staged हैं जब वे सिर्फ disk पर saved हैं।
  2. यह सोचना कि HEAD का हमेशा मतलब main की latest commit है, जबकि यह इस समय checkout जो भी हो उसकी ओर point करता है।
  3. origin को upstream से confuse करना, जबकि origin आपका default remote है और upstream अक्सर एक fork के original project का नाम है।
चैप्टर सारांश
  • GUI tools और editor integrations command line के alternatives offer करते हैं।
  • Git object model, git gc, और maintenance explain करते हैं कि Git data कैसे store करता है।
  • Git LFS, .gitattributes, और एक glossary बड़े projects और terminology support करते हैं।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.