2009-12-10 17 views
85

Próbowałem edytować stary komunikat zatwierdzenia, jak wyjaśniono here.Zmiana starej wiadomości zatwierdzenia na Git

Chodzi o to, że teraz, gdy próbuję uruchomić rebase -i HEAD~5, jest napisane: interactive rebase already started.

Więc staram: git rebase --continue ale mam ten błąd:

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

jakieś pomysły?

Odpowiedz

88

Mówi:

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 

To nie znaczy:

type again git rebase -i HEAD~3

Spróbuj nie wpisując git rebase -i HEAD~3 przy wyjściu z edytora, a to powinno działać dobrze.
(w przeciwnym razie, w danej sytuacji, o git rebase -i --abort konieczna, aby przywrócić wszystko i pozwolić, aby spróbować jeszcze raz)


Jak Dave Vogt wymienia w komentarzach, git rebase --continue jest przejściem do następnego zadania w podścielanie proces, po zmianie pierwszego zatwierdzenia.

Również Gregg Lind wspomina w his answer polecenia reword z 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

pracował z poleceniem --abort. Dzięki –

+2

"git rebase --continue" przechodzi do następnego zadania w procesie przekwalifikowania, po tym, jak zmieniono pierwsze zatwierdzenie. –

+0

Dodawanie [link] (https://help.github.com/articles/changing-a-commit-message/) do artykułu github wiki do zmiany komunikatu zatwierdzenia – Joy

42

FWIW git rebase teraz interaktywny ma "przeredagować" opcji, co czyni ten śluz h mniej bolesne!

9

Można to zrobić w następujący sposób jak @gregg powiedział używać słowa przeredagować

git rebase -i HEAD~n 

Tu n lista ostatnich n zobowiązuje.

Na przykład, jeśli używasz git rebase -i HEAD~4

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

Teraz zastąpić słowo odebrać z przeredagować do popełnienia chcesz edytować wiadomość.

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

Teraz zamknij i zapisz to dostaniesz szansę edycji popełnić wiadomość dla którego użyłeś przeredagować w następujących okien.

Można odwołać oficjalny dokument here oraz

+0

Jest to najprostszy sposób na zrobienie tego. Pracowałam jak wdzięk dzięki :) –

Powiązane problemy