Last active
May 12, 2024 21:55
-
-
Save marcelocarmona/e2971783726320ff3e412c5d75012a0a to your computer and use it in GitHub Desktop.
Cómo deshacer el último commit en git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Existen dos maneras de borrar ese commit: | |
* Eliminando junto al commit las modificaciones que este contiene | |
git reset --hard HEAD~1 | |
* Recuperándolas en el área de trabajo para seguir trabajando en ellas | |
git reset HEAD~1 | |
Create a new branch | |
git checkout -b [name_of_your_new_branch] | |
Fusionar commits | |
git reset --soft HEAD~6 | |
git commit -m 'mensaje de commit' | |
Previamente a ejecutar el comando commit, se pueden (o no) realizar los ajustes adicionales que se consideren necesarios | |
Como disclaimer aclaro que no se deben fusionar commits que ya se hayan pusheado | |
Delete untracked files and directories | |
git clean -df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment