0
0
Gitdevops~10 mins

Creating named stashes in Git - Visual Walkthrough

Choose your learning style9 modes available
Process Flow - Creating named stashes
Make changes in working directory
Run git stash save with a name
Git saves changes as a named stash
List stashes to see the named stash
Apply or drop stash by name or index
This flow shows how you make changes, save them with a name using git stash, then manage those named stashes.
Execution Sample
Git
git stash save "work in progress"
git stash list
Save current changes with the name "work in progress" and then list all stashes.
Process Table
StepCommandActionResult
1git stash save "work in progress"Save current changes with a nameChanges saved as stash@{0} with message "work in progress"
2git stash listList all stashesstash@{0}: WIP on branch: work in progress
3git stash apply stash@{0}Apply named stashChanges reapplied to working directory
4git stash drop stash@{0}Remove named stashstash@{0} deleted
💡 All named stashes managed; working directory clean or restored
Status Tracker
VariableStartAfter Step 1After Step 3After Step 4
Working DirectoryModified filesClean (changes saved)Modified files restoredModified files restored
Stash ListEmptystash@{0}: work in progressstash@{0}: work in progressEmpty
Key Moments - 3 Insights
Why do we give a name when creating a stash?
Naming a stash helps identify it later in the stash list, as shown in step 2 of the execution table.
What happens to the working directory after running 'git stash save'?
The working directory becomes clean because changes are saved in the stash, as seen after step 1 in the variable tracker.
How do you remove a named stash after applying it?
Use 'git stash drop' with the stash name or index, demonstrated in step 4 of the execution table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the stash message saved at step 1?
A"temporary changes"
B"work in progress"
C"bug fix"
D"feature update"
💡 Hint
Check the 'Result' column in step 1 of the execution table.
At which step does the working directory get restored with the stashed changes?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look at the 'Action' and 'Result' columns in the execution table for step 3.
If you do not name a stash, how would the stash list differ?
AIt shows a default message like 'WIP on branch'.
BIt shows no stashes at all.
CIt shows an error message.
DIt automatically deletes the stash.
💡 Hint
Think about the purpose of naming in the stash list shown in step 2.
Concept Snapshot
git stash save "name" saves current changes with a custom name.
Use git stash list to see all stashes with their names.
Apply stash by git stash apply stash@{index}.
Remove stash by git stash drop stash@{index}.
Naming helps track multiple stashes easily.
Full Transcript
This lesson shows how to create named stashes in git. First, you make changes in your files. Then you run 'git stash save "work in progress"' to save those changes with a name. This clears your working directory. You can list all stashes with 'git stash list' to see your named stash. Later, you can apply the stash back with 'git stash apply stash@{0}' and remove it with 'git stash drop stash@{0}'. Naming stashes helps you remember what each stash contains.