CodeBlanks Logo Icon CodeBlanks

Summary - Stash

Combine the stash flow to manage intermediate changes.

Stash workflow summary

git stash provides a clean working directory by safely shelving unfinished work into a stack. You can track all saved stashes and their indexes with git stash list. When restoring, choose pop to discard the entry or apply to keep it for reuse.

git stash push -m "feature work"
git stash list
git stash apply stash@{0}
git stash drop stash@{0}

This toolkit lets you manage in-progress work without cluttering commits when switching branches.

Practice Verify stash apply and list

Apply the stash using git stash apply -q, print the file content with cat site.txt, and show that the entry remains in the stack with git stash list.

Starter code

terminal
git init -q -b main
git config user.name "Kemal"
git config user.email "kemal@example.com"
echo "ana icerik" > site.txt
git add site.txt
git commit -qm "Ilk site"
echo "yeni banner" >> site.txt
git stash push -qm "banner calismasi"

# Stash'i apply ile uygula, dosya icerigini ve listeyi bas

Sample solution

terminal
git init -q -b main
git config user.name "Kemal"
git config user.email "kemal@example.com"
echo "ana icerik" > site.txt
git add site.txt
git commit -qm "Ilk site"
echo "yeni banner" >> site.txt
git stash push -qm "banner calismasi"

git stash apply -q
cat site.txt
git stash list

Expected output

ana icerik
yeni banner
stash@{0}: On main: banner calismasi

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which stash command should a developer choose to apply the same temporary change to multiple branches?

  • git stash clear
  • git stash drop
  • git stash pop
  • git stash apply Correct answer

Explanation: Because git stash apply restores changes without removing the entry, the same stash can be reapplied on another branch.

2 Clear entire stash stack

Question
git stash ____
Answer
git stash clear

Explanation: The git stash clear command permanently deletes all stash entries in the stack.

3 Stash workflow matching

Term Meaning
git stash push Saves changes with a new message
stash@{n} A specific stash index in the stack
Tekrar kullanım Same stash remains after apply
Tam temizlik clear empties the entire stack

All lessons in Intermediate

20 Intermediate final

  1. Branch management
  2. Rebase
  3. Conflict
  4. PR flow