git apply

git

इस्तेमाल

git apply [--check|-3] <patch>

किसी diff फ़ाइल को आपके working tree पर लगाता है; यह commit नहीं बनाता और patch में लिखा लेखक भी नहीं पढ़ता, इसलिए ईमेल से आए patch के लिए am ठीक है।

आम विकल्प

विकल्पअर्थ
--checkreport whether it would apply, change nothing
-3fall back to a three-way merge and leave conflict markers
--indexapply to the working tree and stage it
--cachedapply to the index only
-Rapply in reverse, undoing the patch
-p<n>strip n leading path components
--statshow what the patch touches

उदाहरण

git apply --check fix.patch

tells you if it fits before you try

git apply -3 fix.patch

applies it and leaves conflicts to resolve by hand

git apply -R fix.patch

takes an applied patch back out

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

कैसे पढ़ें

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

आम सवाल

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

किसी diff फ़ाइल को आपके working tree पर लगाता है; यह commit नहीं बनाता और patch में लिखा लेखक भी नहीं पढ़ता, इसलिए ईमेल से आए patch के लिए am ठीक है।

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

git apply [--check|-3] <patch> — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।

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

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

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

man पेज: man git-apply