Git, Stashing
Jump to navigation
Jump to search
Stashing significa esconder, es una técnica que se usa en Git para guardar el trabajo en un determinado momento, evitando hacer un commit de algo que tal vez no lo merezca. El trabajo queda escondido y se puede volver a usar en otro momento más adelante, se aplica como un parche que ejecuta cambios sobre el trabajo actual.
Esconder trabajo actual
git stash
Listar los stashes (escondidos)
git stash list
Recuperar stash (apply)
git stash apply stash@{2} # Recuperar stash con su identificador
git stash apply # Recuperar último stash
git stash pop stash@{2} # Recuperar stash y borrar de lista stash con su identificador
git stash pop # Recuperar último stash y borrar de lista stash
Borrar stash (drop)
git stash drop stash@{2} # Borrar stash con su identificador
git stash drop # Borrar último stash
Deshacer recuperación de stash
No existe un comando per se pero se puede ejecutar lo siguiente, aunque no siempre funciona (aparentemente cuando hay conflictos al aplicar el stash).
git stash show -p stash@{0} | git apply -R # Deshacer stash usando identificador
git stash show -p | git apply -R # Deshacer último stash
Crear una rama a partir de un stash
git stash branch ramaNuevaNombre stashID