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

Git remote Command

git remote आपके phone की contacts list check करके यह देखने जैसा है कि आपके project को share की गई दूसरी जगहों के nicknames क्या हैं, जैसे origin।
Syntax
bash
git remote
git remote add remote_name repository_url
git remote rename old_name new_name
git remote remove remote_name

Remotes List करना

अकेला git remote आपकी repository की जानी हर remote के short names list करता है (आमतौर पर सिर्फ origin); हर name जिस actual URL की ओर point करता है वह भी देखने के लिए -v add करें, fetch और push दोनों के लिए।

उदाहरण: Listing Remotes

bash
git remote
git remote -v

एक Remote Add करना

git remote add <name> <url> आपकी repository को default origin से आगे एक additional remote से connect करता है -- original project के साथ-साथ एक personal fork के साथ collaborate करते समय, या same code को दो अलग hosts पर deploy करते समय उपयोगी।

उदाहरण: Adding a Remote

bash
git remote add upstream https://github.com/original/repo.git

Remotes Rename और Remove करना

git remote rename <old> <new> और git remote remove <name> आपको उन remote connections को साफ करने देते हैं जिनकी अब ज़रूरत नहीं या जिनका नाम गलत रखा गया, आपकी actual commit history को affect किए बिना।

उदाहरण: Renaming and Removing Remotes

bash
git remote rename origin old-origin
git remote remove old-origin

Remote URLs बदलना

अगर एक repository एक नए host में migrate होती है या आपका username बदल जाता है, git remote set-url <name> <new-url> बिना remove और re-add किए यह update करता है कि एक मौजूदा remote कहाँ point करता है।

उदाहरण: Changing Remote URLs

bash
git remote set-url origin https://github.com/newuser/repo.git

Detailed Remote Information दिखाना

git remote show <name> एक specific remote के बारे में detailed information print करता है -- इसका URL, यह कौन सी branches track करता है, और आपकी local branches अपने remote counterparts से ahead, behind, या diverged हैं या नहीं।

उदाहरण: Showing Detailed Remote Information

bash
git remote show origin
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. URL में एक typo के साथ एक remote add करना, ताकि git push fail हो, जबकि git remote -v दिखाता है कि क्या configured है।
  2. पहले से origin exist करते हुए git remote add origin ... चलाना, जो remote origin already exists देता है।
  3. यह भूल जाना कि git remote rename से एक remote rename करना इसकी remote-tracking branches के names भी बदल देता है।

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.