Stash Is Just a Temp Table for Your Changes

You’re halfway through modifying a stored procedure when your phone rings. Production is down. You need to switch to main and fix something immediately.

But you can’t switch branches with uncommitted changes — or if you can, you’ll carry those half-finished modifications into the wrong context. You’re not ready to commit because the code is broken. You need somewhere to park your work temporarily.

Every DBA knows the solution. You need a temp table.

A woman craftsperson at a workbench placing in-progress work into labeled drawers underneath, clearing the bench for urgent work. Multiple stash drawers are visible.

Git Stash Is SELECT INTO #my_changes

That’s it. git stash takes all your uncommitted changes — both staged and unstaged — and parks them in a temporary storage area. Your working directory goes back to a clean state, matching the last commit.

The DBA equivalent:

Your in-progress work is safe. Your workspace is clean. You can now switch branches, fix the production issue, and come back later.

Stash Pop Is INSERT Back + DROP

After you’ve dealt with the emergency:

That applies your stashed changes back to the working directory and removes them from the stash. It’s:

You’re back to exactly where you were before the interruption.

Multiple Stashes: Numbered Temp Tables

You can stash more than once. Each stash gets an index number:

Think of these as #stash_0 and #stash_1. The most recent stash is always stash@{0}.

To apply a specific stash without removing it:

To drop a specific stash you no longer need:

Stash With a Message

Unnamed stashes are like unnamed temp tables — they work, but good luck remembering what’s in them next week. Add a description:

Now git stash list actually tells you something useful instead of just “WIP.”

The Boss Interrupt Pattern

This is the scenario where stash earns its keep. Here’s the complete workflow:

No lost work. No half-committed garbage. No “I’ll just copy this file to my desktop” workarounds.

When to Stash vs. When to Commit

A common question: why not just commit the half-done work?

You can. Some people prefer that. But there’s a reason to prefer stash for truly incomplete work:

Commits are permanent records. They show up in git log. If your half-done code breaks the build, that broken commit is in the history. You’ll either need to clean it up later (interactive rebase — Rebase Is ALTER TABLE on Your Commit History) or live with “WIP: broken, don’t look at this” in your log.

Stashes are temporary by design. They’re meant to be applied and discarded — exactly like temp tables. They don’t pollute your commit history.

Rule of thumb: if the work is at a logical stopping point and the code is functional, commit. If it’s genuinely half-done and broken, stash.

Seeing What’s in a Stash

Before you pop a stash, you might want to peek at what’s inside:

This is like running SELECT * FROM #stash_0 before you insert it back — verify it’s what you expect.

Try This Yourself

The One Sentence to Remember

Git stash is a temp table for your uncommitted changes — park them when interrupted, pop them back when you return.

Previously: Pull, Push, Fetch — It’s Just Backup and Restore Over a Network
Next up: Rebase Is ALTER TABLE on Your Commit History

Got questions? Find me on Bluesky or LinkedIn.