Cómo deshacer la última confirmación en git [duplicar]
Esta pregunta ya tiene una respuesta aquí:
- ¿Cómo deshacer las confirmaciones más recientes en Git? 75 respuestas
Por error, hice git add .
y git commit
en la rama develop
. Pero por suerte, no lo hice git push
.
Así que quería volver a su estado original.
Lo intenté git reset --soft
y git reset HEAD --hard
pero parece que lo he estropeado.
Cómo ¿puedo arreglar esto? Quiero volver al estado original y posiblemente mantener los cambios de código.
166
2 answers
Creo que aún no has metido la pata. Try:
git reset HEAD^
Esto traerá el dir al estado antes de que haya hecho el commit, HEAD^
significa el padre del commit actual (el que ya no desea), mientras mantiene los cambios de él (sin escalonar).
422
Author: guessimtoolate,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-24 18:02:19
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-24 18:02:19
Intente simplemente restablecer la última confirmación
git reset --soft HEAD~1
76
Author: don't angry me,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-24 18:01:38
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-24 18:01:38