git cherry-pick

git

इस्तेमाल

git cherry-pick [-x] <commit>...

किसी एक commit को नए hash के साथ मौजूदा branch पर कॉपी करता है, इसलिए बाद में उस branch को merge करने पर वही बदलाव दो बार दिख सकता है।

आम विकल्प

विकल्पअर्थ
-xnote the original hash in the new message
-napply and stage without committing
-eedit the message
-m <parent>pick a merge commit, choosing a side
<a>..<b>a range; a itself is not included
--continuego on after a conflict
--abortundo the whole pick

उदाहरण

git cherry-pick a1b2c3d

copies that commit onto the current branch with a new hash

git cherry-pick -x a1b2c3d

same, with the source hash recorded in the message

git cherry-pick a1b2c3d^..d4e5f6a

copies a range, this time including a1b2c3d

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

कैसे पढ़ें

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

आम सवाल

Q. git cherry-pick क्या करता है?

किसी एक commit को नए hash के साथ मौजूदा branch पर कॉपी करता है, इसलिए बाद में उस branch को merge करने पर वही बदलाव दो बार दिख सकता है।

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

git cherry-pick [-x] <commit>... — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।

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

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

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

man पेज: man git-cherry-pick