Difference between revisions of "Git, Stashing"
Jump to navigation
Jump to search
(5 intermediate revisions by the same user not shown) | |||
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 3. | |||
==Listar los stashes (escondidos)== | ==Listar los stashes (escondidos)== | ||
Line 15: | Line 17: | ||
git stash apply stash@{2} # Recuperar stash con su identificador | git stash apply stash@{2} # Recuperar stash con su identificador | ||
git stash apply # Recuperar último stash | 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 | |||
</syntaxhighlight> | |||
==Borrar stash (drop)== | |||
<syntaxhighlight lang="bash"> | |||
git stash drop stash@{2} # Borrar stash con su identificador | |||
git stash drop # Borrar último stash | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 28: | Line 39: | ||
git stash branch ramaNuevaNombre stashID | git stash branch ramaNuevaNombre stashID | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Referencias== | |||
* [http://git-scm.com/book/en/v2/Git-Tools-Stashing-and-Cleaning Git-Tools-Stashing-and-Cleaning] | |||
[[Category: Git]] | [[Category: Git]] |
Latest revision as of 18:32, 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 3.
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