GitHub Remote Branch
In this page:
git fetch remote_name
git branch -r
git log remote_name/branch_name
एक Remote-Tracking Branch क्या है?
origin/main जैसी एक remote-tracking branch एक read-only local bookmark है जो record करती है कि आपके last fetch पर remote पर एक branch कहाँ point करती थी -- यह कोई branch नहीं जिसमें आप directly commit करें, यह बस remote की state reflect करती है ताकि Git इसे आपके local काम के against compare कर सके।
उदाहरण: What is a Remote-Tracking Branch?
git fetch origin
git log origin/main
Remote Branches List करना
git branch -r सिर्फ remote-tracking branches list करता है, जबकि git branch -a local और remote-tracking branches साथ list करता है, जो remote पर exist करने वाली हर branch देखने के लिए उपयोगी है भले ही आपने अभी उनमें से किसी को locally checkout न किया हो।
उदाहरण: Listing Remote Branches
git branch -r
git branch -a
origin/main और Local main Branch
local main branch और remote-tracking origin/main branch अलग references हैं जो एक-दूसरे से drift हो सकती हैं -- git log से उन्हें compare करना locally बनाई गई ऐसी commits दिखाता है जो अभी push नहीं हुईं, या दूसरों की बनाई ऐसी commits जो अभी pull नहीं हुईं।
उदाहरण: origin/main and the Local main Branch
git log main..origin/main
git log origin/main..main
Fetch बनाम Pull
git fetch remote से नई commits download करता है और origin/main जैसी remote-tracking branches update करता है बिना किसी local branch या working directory को बदले, जबकि git pull same fetch करता है और फिर तुरंत उन commits को current branch में merge (या rebase) कर देता है।
उदाहरण: Fetch vs Pull
git fetch origin
git pull origin main
एक Remote Branch को Locally Checkout करना
सिर्फ remote पर exist करने वाली एक branch checkout करना, git checkout -b <name> origin/<name> या git switch -c <name> origin/<name> इस्तेमाल करके, एक नई local branch बनाता है जो remote branch track करना शुरू कर देती है, इसलिए future plain git pull और git push commands को exactly पता होता है कि कहाँ sync करना है।
उदाहरण: Checking Out a Remote Branch Locally
git checkout -b feature-x origin/feature-x
origin/mainको एक editable branch मानकर इसमें commit करना, जबकि यह एक read-only bookmark है जिसमें आप directly commit नहीं कर सकते।- बिना
git fetchचलाएorigin/mainके up to date होने की उम्मीद करना, ताकि यह पुरानी information दिखाए। - local
mainकोorigin/mainसे confuse करना, जहाँ merge या pull करने तक दोनों अलग हो सकते हैं।
Chapter Quiz — Complete all 11 topics to unlock
0/11 topics done
Complete these topics first: