Difference between revisions of "Git, Stashing"
Jump to navigation
Jump to search
Line 5: | Line 5: | ||
git stash | git stash | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Nota: El stash más reciente es el 0, si hay tres stash y se crea un cuarto el nuevo es el 0 y el primero es el 4. | |||
==Listar los stashes (escondidos)== | ==Listar los stashes (escondidos)== |
Revision as of 18:29, 27 January 2015
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
Nota: El stash más reciente es el 0, si hay tres stash y se crea un cuarto el nuevo es el 0 y el primero es el 4.
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