2009-12-10 5 views
85

पर पुराना प्रतिबद्ध संदेश बदलें मैं here समझाया गया एक पुराना प्रतिबद्ध संदेश संपादित करने का प्रयास कर रहा था।गिट

बात यह है कि अब जब मैं rebase -i HEAD~5 चलाने की कोशिश करता हूं तो यह interactive rebase already started कहता है।

तो फिर मैं कोशिश: git rebase --continue लेकिन यह त्रुटि आई:

error: Ref refs/heads/master is at 7c1645b447a8ea86ee143dd08400710c419b945b but expected c7577b53d05c91026b9906b6d29c1cf44117d6ba 
fatal: Cannot lock the ref 'refs/heads/master'. 

कोई भी विचार?

उत्तर

88

इसे कहते हैं:

When you save and exit the editor, it will rewind you back to that last commit in that list and drop you on the command line with the following message:

$ git rebase -i HEAD~3 
Stopped at 7482e0d... updated the gemspec to hopefully work better 
You can amend the commit now, with 

यह मतलब यह नहीं है:

type again git rebase -i HEAD~3

नहीं जब संपादक बाहर निकलने git rebase -i HEAD~3 टाइपिंग की कोशिश करो, और यह ठीक काम करना चाहिए।


Dave Vogt के रूप में टिप्पणी में उल्लेख है, (अन्यथा, अपने विशेष स्थिति में, एक git rebase -i --abort सब कुछ रीसेट और आप फिर से कोशिश करने के लिए अनुमति देने के लिए आवश्यकता हो सकती है) git rebase --continue रिबेसिंग में अगले काम के लिए जा रहा के लिए है प्रक्रिया, आपके द्वारा पहली प्रतिबद्धता में संशोधन करने के बाद।

इसके अलावा, Gregg Lindhis answer में उल्लेख है git rebase की reword आदेश:

By replacing the command "pick" with the command "edit", you can tell git rebase to stop after applying that commit, so that you can edit the files and/or the commit message, amend the commit, and continue rebasing.

If you just want to edit the commit message for a commit, replace the command " pick " with the command " reword ", since Git1.6.6 (January 2010) .

It does the same thing ‘ edit ’ does during an interactive rebase, except it only lets you edit the commit message without returning control to the shell. This is extremely useful.
Currently if you want to clean up your commit messages you have to:

$ git rebase -i next 

Then set all the commits to ‘edit’. Then on each one:

# Change the message in your editor. 
$ git commit --amend 
$ git rebase --continue 

Using ‘ reword ’ instead of ‘ edit ’ lets you skip the git-commit and git-rebase calls.

+1

उल्लेख कर सकते हैं। धन्यवाद –

+2

इसके अलावा, पहली प्रतिबद्धता में संशोधन करने के बाद, 'गिट रीबेस --continue' पुन: प्रक्रिया प्रक्रिया में अगले कार्य में जाता है। –

+0

एक लिंक संदेश बदलने के लिए [link] (https://help.github.com/articles/changing-a-commit-message/) को github विकी आलेख में जोड़ना – Joy

42

Fwiw, Git अब इंटरैक्टिव rebase एक "reword" है विकल्प, जो इस म्यूक बनाता है एच कम दर्दनाक!

9

आप के रूप @gregg शब्द का प्रयोग reword

git rebase -i HEAD~n 

यहाँ कहा n पिछले n की सूची करता है यह निम्नलिखित तरीके से कर सकते हैं।

उदाहरण के लिए यदि आप git rebase -i HEAD~4

pick e459d80 Do xyz 
pick 0459045 Do something 
pick 90fdeab Do blah blah blah 
pick 90fdeab Do pqr 

का उपयोग अब शब्द की जगह लेनेसाथ reword के लिए प्रतिबद्ध आप संदेश को संपादित करना चाहते हैं।

pick e459d80 Do xyz 
    reword 0459045 Do something 
    reword 90fdeab Do blah blah blah 
    pick 90fdeab Do pqr 

अब करीब है और इस को बचाने आप संपादित करना संदेश है जिसके लिए आप निम्न विंडो में reword का इस्तेमाल किया है प्रतिबद्ध मौका मिल जाएगा।

साथ ही आप --abort कमांड के साथ काम किया आधिकारिक दस्तावेज here

+0

यह वास्तव में ऐसा करने का सबसे आसान तरीका है। एक आकर्षण की तरह काम किया धन्यवाद :) –