I Never Knew Git Stash Could Do This — A Game-Changer for Context Switching
Adam C. |

As someone who regularly juggles multiple branches and features, I thought I had a decent handle on Git. But today, I discovered a use case that blew my mind — and possibly saved my sanity.

Photo by Amamiya Ryoichi on Unsplash

The Situation

I was deep in the middle of building out an OAuth login flow on a feature branch (with-auth0). I had over 20 files either modified or untracked — not committed yet, because I was still experimenting and refining.

Suddenly, I needed to jump to the master branch to apply a quick fix.

But here’s the problem:

I didn't want to commit my in-progress work (it wasn't ready).

I didn't want to lose my visual diff in VSCode (or any editor).

I definitely didn't want to copy files manually or reset anything.

Enter: git stash push -u -m "your message"

I’d always thought of git stash as something for temporary experiments. But what I didn’t know was that you can safely stash everything — including untracked files — and then get it all back exactly as it was, diffs and all.

Here’s the exact command that worked magic:

git stash push -u -m "auth0 work-in-progress"

-u stashes untracked files (the new files I hadn’t added yet)

-m lets me label the stash, so I know what it is later

After that, my working directory was clean. I could safely:

git checkout master
# make my fix
git commit -am "Hotfix: ..."

Then switch back:

git checkout with-auth0
git stash pop

And like magic — everything came back, exactly where I left off. My code editor still showed my in-progress changes, untracked files, and diffs. Nothing was lost, and I didn’t break my flow.

Lesson Learned

I used to think git stash was only for small tweaks or emergencies. But it turns out, it’s perfect for:

Temporarily saving big, in-progress work

Keeping track of both modified and untracked files

Avoiding commit noise or awkward “WIP” commits

Preserving your diffs so you don’t lose visual context

Now, I feel a lot more confident when switching between branches in the middle of messy development. This is one of those small Git tricks that’s going straight into my everyday toolkit.

TL;DR:
Need to jump branches but don't want to commit or lose untracked files and visual diffs?
Use:

git stash push -u -m "your work in progress"

Then stash pop it back after you're done.
It’s safe. It’s powerful. And I wish I’d known this sooner.