← Back to Git Course | Chapter 4: Remote Repositories | Lesson 1 of 11

Git Remote Introduction

एक remote एक shared cloud drive जैसा है जो आपके project की एक copy रखता है ताकि friends और आप सब अलग-अलग जगहों से इसे पहुँच सकें।
Syntax
bash
git remote -v
git clone repository_url
git push remote_name branch_name

एक Git Remote क्या है?

एक remote बस आपकी repository की एक copy है जो कहीं और hosted है -- आमतौर पर GitHub जैसी किसी service पर -- जो उस shared meeting point की तरह act करता है जहाँ team members files को इधर-उधर email करने के बजाय commits exchange करते हैं।

उदाहरण: What is a Git Remote?

bash
git remote -v

एक Repository Clone करना

एक repository clone करना सिर्फ इसकी files copy नहीं करता -- यह automatically source की ओर वापस एक remote connection (default रूप से origin नाम का) भी configure करता है, इसलिए आपकी local copy को पहले से पता है कि updates कहाँ से fetch करने हैं।

उदाहरण: Cloning a Repository

bash
git clone https://github.com/user/repo.git
git remote -v

Remotes को Push करना

Pushing आपकी local commits को एक remote पर upload करती है, आपके काम को उस तक access रखने वाले हर किसी को visible बनाते हुए -- push करने तक, आपकी commits सिर्फ आपकी अपनी machine पर exist करती हैं, collaborators को invisible।

उदाहरण: Pushing to Remotes

bash
git push origin main

Remotes से Pull करना

Pulling एक remote की नई commits download करता है और उन्हें एक step में आपकी इस समय checked-out local branch में merge कर देता है, जो है कि आप teammates के पहले से pushed changes के साथ कैसे sync रहते हैं।

उदाहरण: Pulling from Remotes

bash
git pull origin main

Fetch बनाम Pull

Fetch और pull related हैं लेकिन distinct हैं: fetch सिर्फ नई commits download करता है और आपको यह decide करने से पहले उन्हें inspect करने देता है कि क्या करना है, जबकि pull उन downloaded commits को तुरंत आपकी current branch में भी merge कर देता है।

उदाहरण: Fetch vs Pull

bash
git fetch origin
git pull origin main
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. एक remote को एक URL से confuse करना, जबकि एक remote origin जैसा एक नाम है जो एक URL की ओर point करता है।
  2. एक remote set करने से पहले git push चलाना और No configured push destination पाना।
  3. यह मान लेना कि एक remote automatically update होता है, जबकि local remote-tracking branches सिर्फ git fetch या git pull के बाद बदलते हैं।

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.