stash list
- Git course
- Intermediate
- Lesson 18/82
- 4 min
Learn to view saved stashes with stash list.
Stash stack and listing
When you stash multiple times, each new entry is pushed onto a stack. You use the git stash list command to inspect the entries in this stack. Entries are listed from newest to oldest with indexes such as stash@{0} and stash@{1}.
git stash list
# stash@{0}: On main: second entry
# stash@{1}: On main: first entryThe newest entry at the top of the stack always receives index zero.
Inspecting stash contents: git stash show
To see which files were modified by a stash entry, run git stash show. You can specify an index to inspect a specific entry: git stash show stash@{1}. To view the line-by-line diff patch, append the -p flag.
git stash show
git stash show -p stash@{0}This lets you safely verify what code was saved before restoring it.
Practice List stash entries
Display the created temporary stash entry using the git stash list command.
Starter code
git init -q -b main
git config user.name "Murat"
git config user.email "murat@example.com"
echo "taban" > dosya.txt
git add dosya.txt
git commit -qm "Taban commit"
echo "degisiklik" >> dosya.txt
git stash push -qm "gecici kayit"
# Stash listesini ekrana basSample solution
git init -q -b main
git config user.name "Murat"
git config user.email "murat@example.com"
echo "taban" > dosya.txt
git add dosya.txt
git commit -qm "Taban commit"
echo "degisiklik" >> dosya.txt
git stash push -qm "gecici kayit"
git stash listExpected output
stash@{0}: On main: gecici kayit
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What is the index of the most recently created stash entry in git stash list output?
- stash@{1}
- stash@{top}
- stash@{0} Correct answer
- stash@{last}
Explanation: Stash is a last-in-first-out (LIFO) stack; the newest entry always receives the stash@{0} index.
2 View stash list
git stash ____
git stash list
Explanation: The git stash list command displays all pending stash entries and their indexes in the stack.
3 Stash list concepts
| Term | Meaning |
|---|---|
git stash list |
Lists all stash entries |
stash@{0} |
The latest stash entry in stack |
git stash show |
Summarizes changed files in stash |
LIFO yığını |
Last added stash appears first |