A cosa serve stash
git stash mette da parte le modifiche non committate per riportare il working tree in stato pulito.
Le basi
git stash
git stash -u
git stash -a
git stash push -m "WIP login"
git stash list
git stash show stash@{0}
git stash show -p stash@{0}
Ripristino
git stash pop
git stash apply stash@{2}
git stash drop stash@{0}
git stash clear
Stashing parziale
git stash push -p
Stashing su un branch diverso
git stash branch new-branch stash@{0}
Insidie comuni
- I file non tracciati non vengono stashati di default.
- Gli stash sopravvivono tra branch.
- Gli stash sono locali.
git stash cleare irreversibile.
Quando i commit battono gli stash
git add -A && git commit -m "WIP"
git reset --soft HEAD^
Recuperare stash persi
git fsck --no-reflog | awk '/dangling commit/ {print $3}'
git stash apply <sha>
Disciplina di nomenclatura
Passare sempre -m con una descrizione.