How to Stash Changes in Git

As the creator of CoreUI and with over 25 years of Git development experience, I’ll show you how to effectively use Git stash to temporarily save and manage uncommitted changes.

Git stash temporarily saves your uncommitted changes and reverts your working directory to match the HEAD commit, allowing you to switch branches or pull updates without committing incomplete work.

# Basic stash operations
git stash                    # Stash current changes with default message
git stash save "work in progress on user feature"  # Stash with custom message
git stash push -m "implementing authentication"    # Modern syntax with message

# Stash specific files
git stash push -m "partial login form" -- src/components/LoginForm.js
git stash -- src/utils/helpers.js src/components/Button.js

# Stash including untracked files
git stash -u                 # Include untracked files
git stash --include-untracked # Same as -u
git stash -a                 # Include all files (untracked and ignored)

# List and view stashes
git stash list               # Show all stashes
git stash show               # Show changes in latest stash
git stash show stash@{1}     # Show specific stash
git stash show -p            # Show detailed diff

# Apply and manage stashes
git stash apply              # Apply latest stash (keeps stash)
git stash apply stash@{2}    # Apply specific stash
git stash pop                # Apply and remove latest stash
git stash pop stash@{1}      # Apply and remove specific stash

# Remove stashes
git stash drop               # Delete latest stash
git stash drop stash@{1}     # Delete specific stash
git stash clear              # Delete all stashes

Git stash is perfect for temporarily saving work when you need to quickly switch contexts. Use descriptive messages with git stash save "message" to identify stashes later. The stash operates as a stack (Last In, First Out), so git stash pop applies the most recent stash. Use git stash apply when you want to keep the stash for potential reuse, and git stash pop when you’re sure you won’t need it again.

Best Practice Note:

In CoreUI development, we frequently use git stash when switching between feature branches or when urgent hotfixes interrupt ongoing work. Stashing keeps our commit history clean while preserving valuable work-in-progress code that isn’t ready for commit.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author