2011-08-05 8 views
55

यदि मैंने किसी संस्करण वाली फ़ाइल की कई पंक्तियों को संशोधित किया है, तो क्या के नियमों को कमांड लाइन द्वारा में परिवर्तन पूर्ववत करना संभव है?क्या संपूर्ण फ़ाइल की बजाय एक लाइन को गिट-चेकआउट करना संभव है?

वैसे ही जैसे मैं के साथ एक पूरी फ़ाइल के लिए करना होगा:

git checkout /path/to/file.extension 

लेकिन जैसे कुछ कर रही है, का कहना है कि

git checkout /path/to/file.extension --line 10 

संभव है?

उत्तर

85

आप प्रत्येक हंक को व्यक्तिगत रूप से देखने के लिए git checkout -p का उपयोग कर सकते हैं और यह तय कर सकते हैं कि उन्हें जांचना है या उन्हें छोड़ना है (और यह वैकल्पिक पथ तर्क भी लेता है, साथ ही यदि आप इसे आगे संकीर्ण करना चाहते हैं)।

24

मैट जवाब पर विस्तार से बता दें git checkout --patch -- <path argument> निम्नलिखित विकल्पों के साथ एक इंटरैक्टिव मोड प्रारंभ:

y - stage this hunk 
n - do not stage this hunk 

q - quit; do not stage this hunk or any of the remaining ones 
a - stage this hunk and all later hunks in the file 
d - do not stage this hunk or any of the later hunks in the file 
g - select a hunk to go to 
/- search for a hunk matching the given regex 
j - leave this hunk undecided, see next undecided hunk 
J - leave this hunk undecided, see next hunk 
k - leave this hunk undecided, see previous undecided hunk 
K - leave this hunk undecided, see previous hunk 

s - split the current hunk into smaller hunks 
e - manually edit the current hunk 

? - print help 

yns और e विकल्प एक अच्छी जगह शुरू करने के लिए कर रहे हैं।

यह भी देखें:

संबंधित मुद्दे