2014-05-09 16:48:06 +0000 2014-05-09 16:48:06 +0000
135
135
Advertisement

¿Hay alguna forma de editar un mensaje de confirmación en GitHub?

Advertisement

¿Hay alguna forma de editar un mensaje de confirmación después de confirmarlo y enviarlo a GitHub? Veo que hay un “añadir una nota”, así como comentarios en línea, pero no hay edición real de un mensaje de confirmación. También hay un “modificar commit” en las extensiones de git, pero eso no edita el mensaje existente.

Advertisement
Advertisement

Respuestas (5)

189
189
189
2014-05-10 10:27:44 +0000
  1. git rebase -i <commit hash you want to change>^

  2. Para cualquier confirmación que desee cambiar el mensaje, cambie pick por reword.

  3. Guarde y salga (en vi: :wq).

  4. Para cada confirmación, obtendrá un editor para editar el mensaje de confirmación. Modifícalo como creas conveniente, guarda y sal.

  5. Ahora puedes subirlos a github usando git push origin --force.

Si sólo necesitas arreglar tu último commit, puedes reemplazar los pasos 1-4 con git commit --amend.

35
35
35
2018-06-18 09:49:45 +0000

En Intellij Idea puedes hacerlo muy fácilmente.

  1. Abrir el control de versiones (historial)
  2. Selecciona la pestaña de registro
  3. 3. Seleccionar commit para cambiar el comentario
  4. Pulsar F2 (Mac fn + F2), y actualizar el mensaje de commit
3
Advertisement
3
3
2019-03-14 07:29:36 +0000
Advertisement

Premisa:

si tu git-graph se parece a …

O target-commit that you want to change its message [df9c192]
|
O parent-commit [b7ec061]
|
O

(df9c192 y b7ec061 son los hashes de commit de target-commit y parent-commit, por separado)

Solución:

puedes simplemente escribir las siguientes instrucciones…

git reset --soft b7ec061
git commit -m "your_new_description"
git push -f

Explicación:

  1. git reset --soft b7ec061 mantendrá los cambios de los archivos y restablecerá el parent-commit (es decir, b7ec061)
  2. git commit -m "..." creará localmente un nuevo commit
  3. git push -f empujará tu nuevo commit al servidor y reemplazará el anterior (i.e. df9c192)
2
2
2
2018-08-08 22:27:59 +0000

Otra opción es crear una “confirmación de errata” adicional (y empujarla) que haga referencia al objeto de confirmación que contiene el error – la nueva confirmación de errata también proporciona la corrección. Una confirmación de errata es una confirmación sin cambios sustanciales en el código, pero con un mensaje de confirmación importante – por ejemplo, añadir un carácter de espacio a su archivo readme y confirmar ese cambio con el mensaje de confirmación importante, o utilizar la opción --allow-empty de git. Es ciertamente más fácil y seguro que rebasar, no modifica la historia real, y mantiene el árbol de ramas limpio (usar amend es también una buena opción si estás corrigiendo el commit más reciente, pero un commit de erratas puede ser una buena opción para commits más antiguos). Este tipo de cosas ocurren tan raramente que simplemente documentar el error es suficiente. En el futuro, si necesitas buscar en el registro de git una palabra clave de una característica, el commit original (erróneo) puede no aparecer porque la palabra clave errónea fue usada en ese commit original (la errata original) – sin embargo, la palabra clave aparecerá en el commit de errata que entonces te dirigirá al commit original que tenía la errata. Este es un ejemplo:

$ git log commit 0c28141c68adae276840f17ccd4766542c33cf1d Author: First Last Date: Wed Aug 8 15:55:52 2018 -0600 Errata commit: This commit has no substantive code change. THis commit is provided only to document a correction to a previous commit message. This pertains to commit object e083a7abd8deb5776cb304fa13731a4182a24be1 Original incorrect commit message: Changed background color to red Correction (\*change highlighted\*): Changed background color to \*blue\* commit 032d0ff0601bff79bdef3c6f0a02ebfa061c4ad4 Author: First Last Date: Wed Aug 8 15:43:16 2018 -0600 Some interim commit message commit e083a7abd8deb5776cb304fa13731a4182a24be1 Author: First Last Date: Wed Aug 8 13:31:32 2018 -0600 Changed background color to red
0
Advertisement
0
0
2019-08-24 11:01:51 +0000
Advertisement

Respuesta de @Mureinik ](https://superuser.com/a/751909/248836) es bueno pero no es comprensible para los novatos.

Primer método:

  1. Si sólo quieres editar el último mensaje de commit, entonces sólo necesitas git commit --amend, verías:
<your existing commit mesage foo bar> 

# Please enter the commit message fir your changes. Lines starting
# with # will be ignored, and an empty message aborts the commit.
#
# Date: Sat Aug 24 17:56:16 2019 +0800
#
# On branch is up to date with 'origin/master'.
#
# changes to be committed:
# modified: foo.py
#
  1. Como puede ver, el mensaje de confirmación en la parte superior sin ningún prefijo de comando como pick, esto ya es la página de edición y puede dirigir editar el mensaje superior y guardar&salir , por ejemplo
<your new correction commit message> 

# Please enter the commit message for your changes. Lines starting
....
  1. Luego haga git push -u origin master --force o <how you push normally> --force. La clave aquí es --force.

Segundo método:

  1. Puedes ver el hash del commit mediante git log o extraerlo de la url del repositorio, el ejemplo en mi caso es 881129d771219cfa29e6f6c2205851a2994a8835

  2. Entonces puedes hacer git rebase --interactive 881129d771219cfa29e6f6c2205851a2994a8835 o git rebase -i HEAD^ (si es el último)

  3. Verías:

pick <commit hash> <your current commit message>

# Rebase 8db7e8b..fa20af3 onto 8db7e8b
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
  1. Pero si ves noop entonces es probable que estés escribiendo mal, por ejemplo, si haces git rebase -i 881129d771219cfa29e6f6c2205851a2994a88 que falta ^ al final, es mejor que salgas del editor sin guardar y averigües la razón:
noop

# Rebase 8db7e8b..fa20af3 onto 8db7e8b
...
  1. Si no hay problema con noop, entonces simplemente cambia la palabra pick por reword , lo demás sólo queda (no editas el mensaje de commit en este punto), e. g:
reword <commit hash> <your current commit message>

# Rebase 8db7e8b..fa20af3 onto 8db7e8b
#
# Commands:
# p, pick = use commit
...
  1. Save&quit verá la página de edición similar al método #1:
<your existing commit mesage foo bar> 

# Please enter the commit message fir your changes. Lines starting
# with # will be ignored, and an empty message aborts the commit.
#
# Date: Sat Aug 24 17:56:16 2019 +0800
#
# interactive rebase in progress; onto b057371
# Last command done (1 command done):
# reword d996ffb <existing commit message foo bar>
# No commands remaining.
# You are currently editing a commit while rebasing branch 'master' on 'b057371'.
#
# changes to be committed:
# modified: foo.py
#
  1. Edite el mensaje de arriba, igual que el método #1 y save&quit, e.g:
<your new correction commit message> 

# Please enter the commit message for your changes. Lines starting
....
  1. De nuevo, igual que el método #1, haga git push -u origin master --force o <how you push normally> --force. La clave aquí es --force.

Para más información por favor lea el doc .

Advertisement

Gerelateerde vragen

19
4
12
9
3
Advertisement