← Back to Git Course | Chapter 2: Basic Commands | Lesson 4 of 18

Git clone Command

git clone एक पूरी book को उसके सारे पुराने edits सहित photocopy करने जैसा है, ताकि आपके पास घर पर पढ़ने और बदलने के लिए अपनी पूरी copy हो।
Syntax
bash
git clone repository_url [directory_name]

git clone क्या है?

git clone <url> एक remote repository की एक complete copy -- हर commit, हर branch, पूरी history -- एक step में आपकी machine पर download करता है, आपको एक पूरी तरह independent local repository देते हुए जो तुरंत काम करने के लिए ready है।

उदाहरण: What is git clone?

bash
git clone https://github.com/user/repo.git

एक Remote URL से Clone करना

Cloning HTTPS या SSH URLs पर काम करता है, और दोनों तरीकों में Git automatically उस source की ओर point करने वाला origin नाम का एक remote connection बनाता है, इसलिए future push और pull commands को exactly पता होता है कि कहाँ sync करना है।

उदाहरण: Cloning from a Remote URL

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

एक Specific Folder में Clone करना

Default रूप से cloned folder का नाम खुद repository के नाम पर होता है, लेकिन git clone <url> <folder-name> आपको एक custom directory name में clone करने देता है -- तब उपयोगी जब आपके पास पहले से उस नाम वाला एक folder हो, या कुछ ज़्यादा descriptive चाहिए हो।

उदाहरण: Cloning into a Specific Folder

bash
git clone https://github.com/user/repo.git my-folder

एक Specific Branch Clone करना

Cloning आमतौर पर सिर्फ default branch checkout करती है, लेकिन git clone --branch <name> <url> आपको सीधे एक specific branch clone और checkout करने देता है, बाद में branches switch करने का extra step skip करते हुए।

उदाहरण: Cloning a Specific Branch

bash
git clone --branch develop https://github.com/user/repo.git

Cloned Remote Check करना

एक clone के तुरंत बाद git remote -v चलाना आपको वह origin URL दिखाता है जो Git ने automatically configure किया -- यह एक quick sanity check है कि आप actually intended repository की ओर pointed हैं।

उदाहरण: Checking the Cloned Remote

bash
git remote -v
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. git clone चलाना और फिर नए folder के अंदर git init चलाना, जबकि clone पहले से एक repository है।
  2. Git commands चलाने से पहले cloned folder में cd करना भूल जाना, ताकि Git not a git repository कहे।
  3. यह उम्मीद करना कि git clone copy को up to date रखेगा, जबकि बाद के changes 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.