git clone

git

इस्तेमाल

git clone [--depth <n>] [-b <branch>] <url> [<directory>]

रिमोट repository को इतिहास के साथ कॉपी करता है; --depth 1 वाले clone में पुराने commit और दूसरी branch नहीं होतीं, बाद में --unshallow चाहिए।

आम विकल्प

विकल्पअर्थ
--depth <n>shallow copy with only the last n commits
-b <branch>check out that branch instead of the default
--single-branchfetch one branch only
--recurse-submodulesclone submodules at the same time
--filter=blob:nonepartial clone: fetch file contents on demand
-o <name>call the remote something other than origin

उदाहरण

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

copies the repository into repo/ and names the remote origin

git clone --depth 1 https://github.com/user/repo.git

fast copy for CI with no old history

git clone -b dev --single-branch <url>

checks out dev and fetches nothing else

उलझन यह है कि पीछे लौटने के कई रूप हैं — ब्रांच का इशारा हटाना और उलटने वाला कमिट जोड़ना एक बात नहीं।

कैसे पढ़ें

  • बड़े कोष्ठक [ ] उस हिस्से को दिखाते हैं जिसे छोड़ा जा सकता है।
  • तीन बिंदु … का मतलब है एक से ज़्यादा दिए जा सकते हैं।
  • विकल्पों में बड़े-छोटे अक्षर मायने रखते हैं — कुछ कमांड में -r और -R अलग काम करते हैं।

आम सवाल

Q. git clone क्या करता है?

रिमोट repository को इतिहास के साथ कॉपी करता है; --depth 1 वाले clone में पुराने commit और दूसरी branch नहीं होतीं, बाद में --unshallow चाहिए।

Q. इसे कैसे लिखें?

git clone [--depth <n>] [-b <branch>] <url> [<directory>] — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।

Q. कितने विकल्प जानने लायक़ हैं?

यहाँ 6 दिए हैं; पूरी सूची man git में है। यह कमांड git में आती है।

मिलती-जुलती कमांड

man पेज: man git-clone