Por Anónimo (no verificado) , 29 Abril 2026

Para qué sirve stash

git stash archiva tus cambios sin commit para que puedas devolver tu árbol de trabajo a un estado limpio, y luego recuperarlos.

Lo básico

git stash                       # stashear archivos rastreados
git stash -u                    # incluir untracked
git stash -a                    # incluir untracked E ignorados
git stash push -m "WIP login"
git stash list
git stash show stash@{0}
git stash show -p stash@{0}

Restaurar

git stash pop                   # aplicar y borrar
git stash apply stash@{2}       # aplicar y conservar
git stash drop stash@{0}
git stash clear

Stash parcial

git stash push -p

Stashear en otro branch

git stash branch new-branch stash@{0}

Trampas comunes

  • Los archivos untracked no se stashean por defecto — usa -u.
  • Los stashes sobreviven entre branches.
  • Los stashes son locales. No hacen push, no son backup.
  • git stash clear es irreversible.

Cuando los commits ganan a los stashes

git add -A && git commit -m "WIP"
# más tarde:
git reset --soft HEAD^

Recuperar stashes perdidos

git fsck --no-reflog | awk '/dangling commit/ {print $3}'
git stash apply <sha>