2009-12-10 13 views
85

Ich habe versucht, eine alte Commit-Nachricht wie erläutert here zu bearbeiten.Ändern Sie alte Commit-Nachricht auf Git

Die Sache ist, dass jetzt, wenn ich versuche, rebase -i HEAD~5 läuft es heißt interactive rebase already started.

Also dann versuche ich: git rebase --continue aber habe diesen Fehler:

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

Irgendwelche Ideen?

Antwort

88

Dort heißt es:

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 

Es bedeutet nicht:

type again git rebase -i HEAD~3

zu Versuchen nichtgit rebase -i HEAD~3 eingeben, wenn Sie den Editor zu verlassen, und es sollte funktionieren.
in den Kommentaren (sonst in Ihrer speziellen Situation, ein git rebase -i --abort könnte alles zurücksetzen und Sie sich erneut versuchen erlauben werden muß), zur nächsten Aufgabe


Wie Dave Vogt erwähnen git rebase --continue im Rebasieren für das Gehen Prozess, nachdem Sie das erste Commit geändert haben.

Auch erwähnt Gregg Lind in his answer den reword Befehl von git rebase:

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

mit dem --abort Befehl Arbeitete beziehen. Danke, –

+2

Auch "Git Rebase - weiter" geht zur nächsten Aufgabe im Rebasing-Prozess, nachdem Sie das erste Commit geändert haben. –

+0

Hinzufügen des [link] (https://help.github.com/articles/changing-a-commit-message/) zum github Wiki-Artikel zum Ändern einer Commit-Nachricht – Joy

42

FWIW, git interaktive rebase jetzt eine "umformulieren" Option hat, was macht dieses muc h weniger schmerzhaft!

9

Sie können diese folgende Art und Weise zu tun, wie @gregg Wort zu verwenden, sagte

git rebase -i HEAD~n 

Hier umformulieren n ist die Liste der letzten n verpflichtet.

Zum Beispiel, wenn Sie git rebase -i HEAD~4

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

Jetzt Wort ersetzen verwenden holen mit umformulieren für begehen Sie Nachricht bearbeiten möchten.

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

Jetzt schließen und diese sparen Sie Chance bekommen, SMS-Text zu bearbeiten verpflichten, für die Sie reword in folgenden Fenstern verwendet haben.

Sie können offizielles Dokument here sowie

+0

Dies ist der einfachste Weg, dies zu tun. Arbeitete wie ein Charme dank :) –

Verwandte Themen