Elena' s AI Blog

Git Stash: The CTRL-Z for Your Working Directory

23 Jan 2026 (updated: 24 Aug 2026) / 7 minutes to read

Elena Daehnhardt


Generated by Midjourney. Prompt: AI-assisted coding with a robot reviewing a pull request.

If you click an affiliate link and subsequently make a purchase, I will earn a small commission at no additional cost (you pay nothing extra). This is important for promoting tools I like and supporting my blogging.

I thoroughly check the affiliated products' functionality and use them myself to ensure high-quality content for my readers. Thank you very much for motivating me to write.



TL;DR:
  • Use 'git stash' to temporarily save your changes without committing. Perfect for switching branches mid-work. Pop them back when you're ready.

Previous: Part 25 — GitHub Gists

Next: Part 27 — Stop Committing Garbage: A Masterclass in .gitignore

Have you ever been in the middle of a complex feature, writing messy code, when suddenly a colleague asks you to fix a critical bug on production?

You can’t commit your broken code. You can’t lose your work. So, what do you do?

You stash it.

Git Stash: Temporarily Saving Uncommitted Changes

git stash is a Git command that temporarily saves uncommitted changes — both staged and unstaged — outside your commit history and reverts your working directory to the last clean commit. It’s one of those commands that feels like magic once you start using it.

Think of git stash as a “Cut and Paste” for your entire project. You cut your current work, go do something else, and paste it back when you’re ready. git stash is a working-directory tool that separates context-switching from commit history, letting you pause and resume work without creating throwaway commits.

Git Stash Command Reference

Command What It Does
git stash Stash all tracked changes (staged + unstaged).
git stash -u Stash tracked and untracked (new) files.
git stash pop Apply latest stash and remove it from the list.
git stash apply Apply latest stash but keep it in the list.
git stash list View all stashed entries with timestamps.
git stash pop stash@{1} Apply a specific entry by index.
git stash drop stash@{0} Delete a specific stash entry.
git stash clear Delete all stash entries permanently.

How to Stash Uncommitted Changes with git stash

🔒 Subscribe to keep reading.

Managing Multiple Git Stash Entries with git stash list

🔒 Subscribe to keep reading.

Including Untracked Files with git stash -u

🔒 Subscribe to keep reading.

Git Stash: Key Takeaways for Daily Git Workflow

🔒 Subscribe to keep reading.

Subscribe to unlock the full article ❤️

I keep most of the site completely open. A few unusually detailed tutorials need a free subscriber login so I can keep publishing this kind of work.

The form below signs you up for the newsletter. It does not log you into the app — log in afterwards (same email) to unlock this article and download your subscriber gifts. New subscribers get an inbox mail: Set a password to unlock articles.

desktop bg dark

About Elena

Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.




Citation
Elena Daehnhardt. (2026) 'Git Stash: The CTRL-Z for Your Working Directory', daehnhardt.com, 23 January 2026. Available at: https://daehnhardt.com/blog/2026/01/23/git-stash/
All Posts