2010-08-26 16 views
12

मैं git-format-patch के साथ किसी और द्वारा बनाई गई गिट पैच को लागू करने का प्रयास कर रहा हूं। पैच हेड के पीछे एक प्रतिबद्धता के खिलाफ किया गया था, लेकिन जैसा कि मैं समझता हूं कि इससे कोई फर्क नहीं पड़ता। जब मैं git am 0001.patch चलाने के लिए, मैं त्रुटि मिलती है:क्या करना है यदि गिट-एम "इंडेक्स से मेल नहीं खाता" के साथ विफल रहता है?

error: source.c: does not match index

मैं Git पैच के प्रारूप के साथ भी परिचित नहीं हूँ, लेकिन यह प्रतीत होता है कि अनुक्रमित मेल नहीं खाते, लेकिन स्रोत मैच नहीं करता है।

इसे ठीक करने का सबसे अच्छा तरीका क्या है? इंडेक्स को मैन्युअल रूप से मिलान करने के लिए बदलें? या मुझे git-apply चाहिए और फिर जब मैं प्रतिबद्ध हूं तो लेखक और विवरण जानकारी की प्रतिलिपि बनाना चाहिए?

उत्तर

11

J.C. Hamano (Git maintainer) himself से, इस बारे में है:

patch applications and merges in a dirty work tree with a clean index.

  • A dirty work tree is where you have changes that are not added to the index.
    A work tree that is not dirty is a clean work tree.
  • A dirty index is where you have changes already added to it (in other words, " git diff --cached " will report some changes).
    A clean index matches the HEAD.
हाल Git रिलीज के साथ

, आप गर्भपात कर सकते हैं:

To restore the original branch and stop patching run " git am --abort ".

तब:

The simplest thing for those who cannot decide may be to stash the changes away for later.

$ git stash save "Random changes that are not ready" 

And then redo " git pull " or " git am ".
" git stash " is the ultimate tool for people who are afraid of commitment.

After redoing " git pull " or " git am ", you can replay the local changes you stashed away:

$ git stash pop 

नोट: गंदा पेड़ का एक स्रोत autocrlf सेटिंग (इस msysgit issue 81 में) की तरह हो सकता है, इसलिए sure to set that to false बनाते हैं।
विसंगति का अन्य स्रोत: core.whitespace setting

Before trying to run git am I did run git stash , so I don't think that was the problem.
What I ended up doing was running git am -3 patch.patch, then manually fixing the problem, then running ' git am --resolved '.

नोट:: हाल Git1.7.2 Release Notes में:

The message from " git am -3 " has been improved when conflict resolution ended up making the patch a no-op.

+0

प्रतिक्रिया के लिए धन्यवाद। Am' मैं' Git stash' चलाने था, इसलिए मुझे नहीं लगता कि 'Git भागने की कोशिश कर इससे पहले कि समस्या क्या मैं चल रहा था कर समाप्त हो गया था। 'Git बजे -3 patch.patch', फिर समस्या को मैन्युअल रूप से ठीक करना, फिर 'git am --resolved' चला रहा है। – joshdoe

+0

@joshdoe: प्रतिक्रिया के लिए धन्यवाद। मैंने इसे उत्तर में शामिल किया है। – VonC

1

मेरे लिए मैं git (CentOS -6 के एक पुराने संस्करण पर हूँ


ओपी टिप्पणी में उल्लेख है distro)।

मैं ऐसा करके इस मुद्दे को ठीक करने में सक्षम था:

  • git update-index --refresh
  • git am ${patch_filename}

क्यों यह काम करता है के बारे में अधिक पढ़ने के लिए। जाँच कृपया the original source here:

"

मैं एक तरह से हैरान है कि हम ऐसा नहीं किया है पहले से ही 'ताज़ा एक बार अग्रिम' और कोई भी कभी भी पिछले 5 वर्षों के लिए इस में चलाने हूँ ऐसा लगता है कि मुझे लगता है कि विरासत में मिला। गिट-एडोबंबॉक्स से व्यवहार ;-)

शुरुआत में एक बार रीफ्रेश करना और को "am --resolved" के साथ पुनरारंभ करना समझदार है।

"

+0

मैंने जवाब देने का प्रयास किया लेकिन किया मेरे लिए काम नहीं करता। 'गिट अपडेट-इंडेक्स - रीफ्रेश' कमांड ने मेरे लिए एक चाल बनाई। – mask

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