2009-12-10 25 views
85

Stavo cercando di modificare un vecchio messaggio di commit come spiegato here.Cambia vecchio messaggio di commit su Git

Il fatto è che ora, quando provo a eseguire rebase -i HEAD~5, dice interactive rebase already started.

Allora provo: git rebase --continue ma ottenuto questo errore:

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

Tutte le idee?

risposta

88

Dice:

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 

Non significa:

type again git rebase -i HEAD~3

Prova a non digitando git rebase -i HEAD~3 quando si esce l'editor, e dovrebbe funzionare bene.
(in caso contrario, nella vostra particolare situazione, potrebbero essere necessari un git rebase -i --abort per azzerare tutto e permetterà di provare ancora una volta)


Come Dave Vogt menzioni nei commenti, git rebase --continue è per andare al prossimo compito nel ribasamento processo, dopo aver modificato il primo commit.

Inoltre, Gregg Lind menzioni his answer comando reword di 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

Ha lavorato con il comando --abort. Grazie –

+2

Inoltre, 'git rebase --continue' passa all'attività successiva nel processo di rebasing, dopo aver modificato il primo commit. –

+0

Aggiunta del [collegamento] (https://help.github.com/articles/changing-a-commit-message/) all'articolo di github wiki per la modifica di un messaggio di commit – Joy

42

FWIW, git rebase interattivo ha ora un "riformulare" opzione, che rende questo muc h meno doloroso!

9

Si può fare questo modo seguente come @gregg detto di usare la parola riformulare

git rebase -i HEAD~n 

Qui n è la lista delle ultime n impegna.

Ad esempio se si utilizza git rebase -i HEAD~4

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

Ora sostituire parola raccogliere con riformulare per commettere che si desidera modificare il messaggio.

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

Ora chiudere e salvare questo avrete la possibilità di modificare commettere messaggio per il quale è stato utilizzato riformulare nel seguire le finestre.

È possibile fare riferimento documento ufficiale here così

+0

Questo è in realtà il modo più semplice per farlo. Ha funzionato come un fascino grazie :) –

Problemi correlati