git submodule

git

इस्तेमाल

git submodule update --init --recursive

किसी दूसरे repository को एक commit पर स्थिर करके आपके repository के भीतर रखता है; सादा clone उस फ़ोल्डर को update --init तक खाली छोड़ देता है, और parent branch नहीं, commit पकड़ता है।

आम विकल्प

विकल्पअर्थ
add <url> <path>pin another repository at a path
update --initfill in a submodule folder that a clone left empty
--recursivego into submodules of submodules
update --remotemove the pin to the tip of the tracked branch
statusthe commit each submodule sits at
deinit <path>unregister it
foreach <cmd>run a command in each one

उदाहरण

git submodule update --init --recursive

the command that fills empty submodule folders after a clone

git submodule add https://github.com/x/lib.git vendor/lib

adds a dependency as a submodule

git submodule update --remote

updates the pinned commit to the branch tip

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

कैसे पढ़ें

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

आम सवाल

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

किसी दूसरे repository को एक commit पर स्थिर करके आपके repository के भीतर रखता है; सादा clone उस फ़ोल्डर को update --init तक खाली छोड़ देता है, और parent branch नहीं, commit पकड़ता है।

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

git submodule update --init --recursive — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।

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

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

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

man पेज: man git-submodule