Git Glossary
In this page:
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
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
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
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
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
git log --oneline
git log a1b2c3d --oneline
- working directory और staging area को mix up करना, और यह मान लेना कि changes staged हैं जब वे सिर्फ disk पर saved हैं।
- यह सोचना कि
HEADका हमेशा मतलबmainकी latest commit है, जबकि यह इस समय checkout जो भी हो उसकी ओर point करता है। 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 करते हैं।
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: