Git fetch Command
In this page:
git fetch remote_name
git fetch remote_name branch_name
Git Fetch क्या है?
git fetch एक remote repository से नई commits, branches, और tags आपके local database में download करता है -- लेकिन critically, यह कभी आपकी working files या current branch नहीं छूता, इसे यह check करने का एक completely safe तरीका बनाते हुए कि क्या बदला।
उदाहरण: What is Git Fetch?
git fetch origin
Fetch बनाम Pull
git pull से key difference यह है कि fetch download करने के बाद रुक जाता है: यह आपकी remote-tracking branches (जैसे origin/main) update करता है लेकिन आपकी actual local branches untouched छोड़ता है, आपको कुछ भी merge करने से पहले git diff या git log से incoming changes review करने देते हुए।
उदाहरण: Fetch vs Pull
git fetch origin
git log origin/main
Specific Branches Fetch करना
git fetch origin <branch> remote की हर branch के बजाय सिर्फ एक specific branch target करता है, जो बड़ी repositories पर time और bandwidth बचाता है जहाँ आपको सिर्फ काम की एक line के updates की परवाह हो।
उदाहरण: Fetching Specific Branches
git fetch origin feature-x
Obsolete Branches Pruning करना
जब teammates remote पर branches delete करते हैं, उन्हें आपकी local remote-tracking references stale हो सकती हैं; git fetch --prune उन्हें automatically साफ करता है, उन branches को local references delete करते हुए जो अब remote पर exist नहीं करतीं।
उदाहरण: Pruning Obsolete Branches
git fetch --prune
Dry Run Fetching
git fetch --dry-run exactly दिखाता है कि एक real fetch actually download किए बिना क्या download करेगा -- actual transfer commit करने से पहले आपका connection test करने या incoming changes preview करने का एक lightweight तरीका।
उदाहरण: Dry Run Fetching
git fetch --dry-run
- यह उम्मीद करना कि
git fetchआपकी files बदल देगा, जबकि यह सिर्फ remote-tracking branches update करता है और आपकी working directory unchanged छोड़ता है। git fetchचलाना और यह सोचना कि आप up to date हैं, जबकि commits लाने के लिए आपको अभी भीgit merge origin/mainचाहिए।- एक ऐसा branch name fetch करना जो remote पर exist नहीं करता, जैसे
git fetch origin featur, जो एकcouldn't find remote referror देता है।
Chapter Quiz — Complete all 11 topics to unlock
0/11 topics done
Complete these topics first: