Stashing: Temporary Storage
Half-finished test scripts on your machine and a hotfix that needs verifying in the next ten minutes. git stash is the pocket you put the first thing into so you can deal with the second.
Why This Module Matters
Interruption is the normal state of QA work. You are mid-way through rewriting a fixture when a build with a critical fix lands and someone asks, politely but urgently, whether it works.
Committing unfinished work to make the switch is ugly — you get a commit that says "wip" and doesn't run. Copying files to your Desktop is worse. git stash exists exactly for this: it takes everything you have changed but not committed, puts it on a stack, and returns your working directory to a clean state in one command. Ten minutes later, one more command puts it all back.
The tool is simple. The pitfalls are the interesting part — stashes are silent about untracked files, they are local-only and invisible to your team, and a forgotten stash can sit in a repository for a year holding work someone thought was lost.
What You'll Learn
- When a stash is the right tool, and when committing to a branch is better
git stash push -m "message"and why an unnamed stash is a future puzzlegit stash listand reading thestash@{0}reference- The real difference between
pop,applyanddrop -ufor untracked files, and the classic surprise when you forget it- Why stashes never leave your machine, and what that means for handovers
Pro Tip
Always give a stash a message. stash@{2}: WIP on main: 8f3c2a1 Update config tells you nothing three days later; stash@{2}: On main: half-done retry logic for flaky checkout test tells you everything.