2009-12-10 15 views
85

Estaba intentando editar un mensaje de confirmación anterior como se explica here.Cambiar el mensaje de confirmación anterior en Git

La cosa es que ahora, cuando trato de ejecutar rebase -i HEAD~5 dice interactive rebase already started.

Así entonces trato: git rebase --continue pero tiene este error:

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

¿Alguna idea?

Respuesta

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 

No significa:

type again git rebase -i HEAD~3

Tratar de no escribir git rebase -i HEAD~3 al salir del editor y que debería funcionar bien.
(de lo contrario, en su situación particular, una git rebase -i --abort podrían ser necesarios para reiniciar todo y permitirá probar de nuevo)


Como Dave Vogt menciones en los comentarios, git rebase --continue es para ir a la siguiente tarea en el cambio de base proceso, después de haber enmendado la primera confirmación.

Además, Gregg Lind menciones en his answer el comando reword de 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

Trabajado con el comando --abort. Gracias –

+2

Además, 'git rebase --continue' va a la siguiente tarea en el proceso de rebase, después de haber enmendado la primera confirmación. –

+0

Agregar el [enlace] (https://help.github.com/articles/changing-a-commit-message/) al artículo de github wiki para cambiar un mensaje de confirmación – Joy

42

Fwiw, git rebase interactivo tiene ahora una "reformular" opción, que hace que este h menos doloroso!

9

Usted puede hacer esto después de manera que dicho @gregg utilizar la palabra reformular

git rebase -i HEAD~n 

Aquí n es la lista de las últimas n se compromete.

Por ejemplo, si utiliza git rebase -i HEAD~4

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

Ahora sustituir la palabra recoger con reword para cometer desea editar mensajes.

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

Ahora cierre y guardar esta obtendrá la oportunidad de editar mensaje de consignación para el que ha utilizado reword en el seguimiento de las ventanas.

Puede remitir el documento oficial here así

+0

Esta es la forma más simple de hacer esto. Trabajaron como un encanto, gracias :) –

Cuestiones relacionadas