Back
GitoryxGitoryx
Beginner8 min read

Git Stash Tutorial: Save Work Without Committing

Git stash is one of the most useful commands for switching tasks without losing your work. This tutorial explains how to stash, list, apply, and drop stashes with practical examples.

The Problem

You're in the middle of a feature when a colleague pings: 'Can you quickly check out the bug on the login page?' You have half-finished changes everywhere. You're not ready to commit — and you can't switch branches with uncommitted changes.

Git stash lets you save your current work in progress without making a commit, switch to another task, and come back exactly where you left off. It's an essential daily-use command for any developer.

Common mistakes developers make with this:

  • Losing stashes by accidentally dropping them
  • Stashing and forgetting — then wondering where your work went
  • Not naming stashes, making it impossible to tell them apart later
  • Not knowing stash doesn't save untracked files by default

Gitoryx: Gitoryx shows all your stashes in a dedicated panel with their timestamps and messages. Apply, drop, or create a branch from a stash in one click.

What is Stash Tutorial: Save Work Without Committing?

Git stash temporarily shelves changes you've made to your working directory so you can switch context. The stashed changes are saved in a stack and can be reapplied later with `git stash apply` or `git stash pop`.

Step-by-Step Guide

1

Stash your current changes

Run `git stash` to save all tracked modified files and staged changes. Your working directory becomes clean.

bash
# Basic stash — saves tracked changes
git stash

# Stash with a descriptive message (recommended)
git stash push -m "WIP: user profile form validation"

# Stash including untracked files
git stash push --include-untracked -m "WIP: new auth module"

# Stash including untracked AND ignored files
git stash push --all -m "full workspace snapshot"

Always add a message with `-m`. After a few days, 'WIP on main: a3b2c1d message' means nothing.

2

List your stashes

Stashes are stored as a stack. The most recent stash is `stash@{0}`. List all stashes to find what you saved.

bash
git stash list

# Output:
# stash@{0}: On feature/auth: WIP: user profile form validation
# stash@{1}: On main: WIP: dark mode toggle styles
# stash@{2}: On main: hotfix experiment
3

Inspect a stash before applying

Before restoring a stash, check what changes it contains.

bash
# View a summary of changed files in stash@{0}
git stash show

# View the full diff of stash@{0}
git stash show -p

# Inspect a specific stash by index
git stash show -p stash@{1}
4

Apply a stash

Use `git stash pop` to apply and remove the stash from the stack, or `git stash apply` to apply it and keep it in the stack.

bash
# Apply the most recent stash and remove it from the stack
git stash pop

# Apply a specific stash and keep it in the stack
git stash apply stash@{1}

# Apply the most recent stash to a different branch
git checkout other-branch
git stash pop

Use `git stash pop` for everyday use. Use `git stash apply` when you want to apply the same stash to multiple branches.

See this workflow in Gitoryx — Gitoryx demo

See this workflow in Gitoryx. All stashes are listed in a dedicated panel with their branch, timestamp, and message.

Free download
5

Create a branch from a stash

If applying a stash causes conflicts (because the base branch changed significantly), create a new branch from the stash directly.

bash
# Create a new branch from stash@{0} and apply it there
git stash branch feature/profile-form stash@{0}

# This is equivalent to:
# git checkout -b feature/profile-form <stash-base-commit>
# git stash apply stash@{0}
# git stash drop stash@{0}
6

Clean up stashes

Remove individual stashes or clear the entire stack when you no longer need them.

bash
# Drop a specific stash
git stash drop stash@{1}

# Drop the most recent stash
git stash drop

# Clear ALL stashes (irreversible)
git stash clear

`git stash clear` is permanent. Stash entries are not recoverable once cleared (unless you know the object SHA from `git fsck`).

Common Mistakes to Avoid

Stashing untracked files without --include-untracked

By default, `git stash` only saves tracked, modified files. New files you've created (untracked) are left behind — and switching branches leaves them visible.

Fix: Use `git stash push --include-untracked` (or `-u`) to include new, untracked files in the stash.

Using unnamed stashes

After a week with a dozen stashes, `stash@{3}: WIP on main: a1b2c3 fix button styles` tells you almost nothing.

Fix: Always name your stashes: `git stash push -m 'WIP: descriptive name'`.

Using git stash pop on the wrong branch

Popping a stash on a branch that diverged from where the stash was created can cause unexpected conflicts.

Fix: Check `git stash show` first to see what branch and commit the stash was made on before applying.

Gitoryx — visual Git client for macOS, Windows & Linux
GitoryxGitoryx — macOS, Windows & Linux

Manage Git Stashes Visually in Gitoryx

  • All stashes are listed in a dedicated panel with their branch, timestamp, and message.
  • Create a stash with a name from the Gitoryx UI — no flags to remember.
  • Apply, pop, or drop any stash with one click directly from the stash panel.
  • Gitoryx shows a diff preview for each stash so you can inspect changes before applying.
  • Create a branch from a stash in one step — Gitoryx handles the underlying commands automatically.
Download Gitoryx — FreemacOS · Windows · Linux · No subscription

Frequently Asked Questions

What does git stash do?

Git stash temporarily saves your current working directory and staging area changes without making a commit. It cleans your working directory so you can switch branches, then reapply your changes later.

What is the difference between git stash pop and git stash apply?

`git stash pop` applies the stash and removes it from the stash stack. `git stash apply` applies the stash but keeps it in the stack so you can apply it again later or to another branch.

Does git stash save untracked files?

No, by default `git stash` only saves tracked (already added to git) modified files. To include untracked files, use `git stash push --include-untracked`. To include all files (including ignored), use `--all`.

How do I stash only specific files?

Use `git stash push -- path/to/file` to stash a specific file. For multiple files: `git stash push -- file1 file2`.

How do I recover a dropped stash?

Run `git fsck --no-reflog | awk '/dangling commit/ {print $3}'` to find orphaned commits. Then `git stash apply <SHA>` to restore it. This only works before Git garbage-collects the objects.

Can I stash on one branch and apply on another?

Yes. Stashes are not tied to a specific branch. Use `git stash apply` on any branch. If the base code has changed significantly, you may encounter merge conflicts when applying.

How many stashes can I have?

There is no built-in limit. Git stashes are stored as commits in `refs/stash` and can accumulate indefinitely. Keep your stash list clean by dropping stashes you no longer need.

What is git stash branch?

`git stash branch <name>` creates a new branch starting from the commit where the stash was created, then applies and drops the stash. Useful when applying a stash causes conflicts on the current branch.

See it in action with Gitoryx

Everything in this tutorial is faster and clearer with a visual Git client. Gitoryx is free, runs natively on macOS, Windows, and Linux, and built for developers who want to move fast without breaking things.