Komitly
BlogPricing
Home/Blog/git stash: Save Work Without Committing
WorkflowBeginner

git stash: Save Work Without Committing

Komitly·February 26, 2026·6 min read
git stashgit stash poptemporary changesworkflow
Loading article...

On this page

  • Why stash?
  • Basic stash workflow
  • Stash list and apply
  • Stash with a message
  • Stash specific files
  • Stash management in Komitly
  • Common scenarios

Try it visually with Komitly

Stop memorizing commands. See your branches, commits, and merges in a beautiful visual interface.

Download Komitly — Free

Related articles

WorkflowBeginner

Your First Pull Request: A Complete Workflow

Walk through the complete pull request workflow from branch to merge. Learn branch naming conventions, how to write a good PR, and manage the review process.

git switch -cgit push -ugit rebase
10 min
WorkflowBeginner

.gitignore: Keeping Secrets and Junk Out of Your Repo

Learn how to use .gitignore to exclude dependencies, build output, secrets, and OS files from your repository. Includes pattern syntax, templates by language, and how to untrack already committed files.

git rm --cachedgit check-ignoregit add
8 min
WorkflowBeginner

Writing Better Commit Messages: A Practical Guide

Learn how to write clear, useful commit messages. Covers the subject-body-footer structure, Conventional Commits, and AI tools that help you write better messages.

git commitgit commit -mgit log --oneline
9 min

© 2026 Komitly

support@komitly.com
BlogPricingChangelogTermsPrivacy

Why stash?

You are in the middle of writing a new feature. Files are modified, ideas are half-formed, and nothing is ready to commit. Then a teammate pings you: "Can you review this pull request?" or "There is a bug in production — we need a hotfix."

You need to switch branches, but Git will not let you switch if your uncommitted changes conflict with the target branch. You could make a quick "WIP" commit, but that pollutes your history with meaningless snapshots. This is exactly the problem git stash solves.

git stash takes your uncommitted changes — both staged and unstaged — and saves them on a stack. Your working directory is restored to a clean state, letting you switch branches freely. When you are ready, you pop the stash and your changes come back.

Think of it as putting your work-in-progress in a drawer. The desk is clean, you handle the interruption, then you open the drawer and pick up right where you left off.

Basic stash workflow

The most common stash workflow involves four steps: stash your changes, switch branches, do what you need to do, and then come back and restore your work.

Check modified files
Stash everything
bash
git switch main\n# ... fix the bug, commit, push ...\ngit switch feature/login
Pop the stash

That is the entire workflow. git stash saves, git stash pop restores and removes. For most day-to-day interruptions, these two commands are all you need.

Stash list and apply

Git does not limit you to a single stash. Every time you run git stash, a new entry is pushed onto a last-in-first-out stack. You can view all stash entries with git stash list:

View all stashes

Each entry has an index: stash@{0} is the most recent, stash@{1} is the one before that, and so on. The description includes the branch name and commit message from when the stash was created.

apply vs pop

There are two ways to restore a stash, and the difference matters:

  • git stash pop — applies the changes and removes the stash entry from the stack. Use this when you are done with the stash.
  • git stash apply — applies the changes but keeps the stash entry. Use this when you want to apply the same changes to multiple branches.

You can target a specific stash entry by passing its index:

Apply a specific stash

Dropping a stash

If you used apply and no longer need the stash entry, or if a stash has become outdated, remove it with git stash drop:

Remove a stash entry

To clear the entire stash stack at once, use git stash clear. Be careful with this — it removes all stash entries permanently with no confirmation prompt.

Stash with a message

The default stash description includes the branch name and the latest commit message, which is often not very helpful when you have multiple stashes. A much better practice is to add a descriptive message using the -m flag:

Stash with a message
$ git stash push -m "WIP: login form validation"

Hover over each part to see what it does

Notice the difference in the stash list output. The first entry now reads WIP: login form validation instead of a generic commit hash reference. When you come back hours or days later, this message tells you exactly what work is saved there.

Always use -m when stashing. Your future self will thank you when looking at a stash list with five entries and trying to figure out which one has the code you need.

Stash specific files

Sometimes you do not want to stash everything. Maybe you are working on two unrelated changes and only need to set one aside. The git stash push command lets you specify individual file paths after a -- separator:

Stash a single file
$ git stash push -- src/utils/validate.ts

Hover over each part to see what it does

Only src/utils/validate.ts was stashed. The changes to LoginForm.tsx remain in the working tree, untouched. This gives you fine-grained control over what gets set aside.

You can combine a message with specific files for maximum clarity:

Stash specific files with a message

Another useful variant is git stash push -p (patch mode), which lets you interactively select individual hunks within files to stash. This is the most precise option but requires stepping through each change one by one.

Stash management in Komitly

Managing stashes from the command line works, but the terse output of git stash list does not show you much. You cannot see which files are in each stash without running additional commands, and applying the wrong stash can lead to unexpected conflicts. Komitly makes stash management visual and safe.

Komitly — Stash View
Staged (1)
Asrc/styles/login.css
Changes (2)
Msrc/components/LoginForm.tsx
Msrc/utils/validate.ts
WIP: login form validation
Commit
stash@{WIP: login form validationstash
a3b1c9dAdd login pagefeature/login
7f2e4a1Fix header layoutmain
c8d9e0fAdd settings model
b5a4d3cInitial commit

The staging panel on the left shows the files in a stash entry with their status — modified, added, or deleted. The commit graph on the right shows where the stash was created relative to your branch history, so you always know the context.

Komitly adds several stash features that go beyond what the command line offers:

  • Stash file picker — instead of applying an entire stash, you can select individual files to restore. This is like git checkout stash@{0} -- path but with a visual file list and checkboxes.
  • Stash diff preview — click any file in a stash to see its full diff before deciding whether to apply it. No more guessing what a stash contains.
  • Smart auto-stash — enable auto-stash in settings and Komitly will automatically stash your changes when switching branches, then pop them when you switch back. The stash message includes the source and target branch so you always know what happened.
  • Context menu operations — right-click any stash entry to apply, pop, drop, or browse its file tree, all with confirmation prompts to prevent accidents.

The file picker feature is especially useful when a stash contains changes to many files but you only need a few of them. Select the files you want, click apply, and only those files are restored to your working directory.

Common scenarios

Now that you know the commands, here are the real-world situations where stashing shines.

Quick hotfix

The most classic stash scenario: you need to drop everything and fix a production bug. Stash, switch to main, create a hotfix branch, fix the issue, and then come back.

Hotfix workflow with stash

Code review on another branch

A teammate asks you to review their pull request. You need to check out their branch to run the code locally. Stash your current work, check out their branch, review, and switch back:

bash
git stash push -m "WIP: before reviewing PR #42"
git switch feature/teammate-branch
# ... review, test, leave comments ...
git switch feature/login
git stash pop

Experimentation

You want to try a different approach to solving a problem without losing your current attempt. Stash your work, experiment freely, and if the experiment fails, discard the changes and pop your stash to get back to the original approach:

bash
git stash push -m "Approach A: recursive solution"
# ... try approach B ...
# If approach B doesn't work:
git checkout .
git stash pop
# You're back to approach A

Pulling with uncommitted changes

Sometimes git pull will refuse to run because your local changes conflict with incoming changes. A quick stash solves this:

bash
git stash
git pull
git stash pop
# Resolve any conflicts if they arise

If conflicts occur when popping, Git will leave the stash entry in place (it only removes it on a clean apply) and mark the conflicting files. Resolve the conflicts as you would with any merge, then drop the stash manually with git stash drop.

Stashing is a temporary tool. If you find yourself accumulating many stashes, consider whether those changes should be proper commits on a feature branch instead. Stashes have no branch association, no meaningful history, and can be accidentally dropped. Use them for short-lived interruptions, not long-term storage.