Git pull Command
In this page:
git pull remote_name branch_name
git pull --rebase remote_name branch_name
Git Pull क्या है?
git pull sequence में दो operations का shorthand है: यह एक remote से नई commits fetch करता है, फिर उन्हें तुरंत आपकी इस समय checked-out branch में merge करता है, same step में आपकी working files update करते हुए।
उदाहरण: What is Git Pull?
git pull origin main
Git Pull कैसे काम करता है
Under the hood, git pull पहले आपकी remote-tracking branch (जैसे origin/main) को server से match करने के लिए update करता है, फिर उस updated reference और आपकी local branch के बीच एक normal merge चलाता है।
उदाहरण: How Git Pull Works
git fetch origin
git merge origin/main
Rebase के साथ Pull करना
Default रूप से वह merge step एक merge commit बनाता है अगर histories diverge हुई हों; git pull --rebase इसके बजाय merge को rebase से replace करता है, आपके project की history को हर sync पर branch होने के बजाय linear रखते हुए।
उदाहरण: Pulling with Rebase
git pull --rebase origin main
Remote से एक Specific Branch Pull करना
git pull origin <branch> आपको किसी भी branch सीधे आपके local database में pull करने देता है, सिर्फ जो branch आपने इस समय checkout की है वह नहीं -- पहले switch किए बिना teammate की branch लाने के लिए उपयोगी। git pull origin <branch> चलाना जब उस नाम की कोई local branch अभी exist न करे तब भी पहले इसे track करने वाली एक local branch checkout करना ज़रूरी है -- git checkout --track origin/<branch> (या git switch -c <branch> origin/<branch>) वह local branch बनाता है, और बाद में एक plain git pull इसे remote branch की latest commits के साथ updated रखता है।
उदाहरण: Pulling a Specific Branch from Remote
git pull origin feature-x
Pull Conflicts Handle करना
अगर आपके local uncommitted changes incoming remote changes से conflict करें, git pull कुछ भी चुपचाप overwrite करने के बजाय एक error के साथ pause हो जाता है -- pull आगे बढ़ने से पहले आपको अपने local changes commit, stash, या discard करने होंगे।
उदाहरण: Handling Pull Conflicts
git pull origin main
# error: local changes would be overwritten
git stash
git pull origin main
- same files छूने वाले uncommitted changes के साथ
git pullचलाना, एक error या conflict का कारण बनते हुए। - यह जाने बिना pull करना कि यह merge करता है, ताकि एक unexpected merge commit दिखे;
git pull --rebaseइससे बचाता है। - गलत branch पर
git pullचलाना, गलती से remote changes को एक feature branch में merge करते हुए।
Chapter Quiz — Complete all 11 topics to unlock
0/11 topics done
Complete these topics first: