This Git error occurs when you attempt to apply, pop, or drop a stash but no stashes exist in your stash list. The stash may have already been applied, dropped, or was never created in the first place.
The error "No stash entries found" appears when you run a git stash command that expects to operate on an existing stash, but the stash list is empty. This commonly happens with commands like `git stash pop`, `git stash apply`, `git stash drop`, or `git stash show`. Git's stash is a stack-based storage mechanism that temporarily saves uncommitted changes so you can switch branches or pull updates without committing work in progress. When you "pop" a stash, Git applies the changes and removes the stash entry from the list. This error typically occurs when: - The stash was already applied and dropped by a previous `git stash pop` - The stash list was cleared with `git stash clear` - A stash was never created in the first place - The stash was dropped manually with `git stash drop` - You're in a different repository than where the stash was created
First, confirm that there are no stash entries:
# List all stash entries
git stash listIf this returns nothing (no output), the stash list is empty. If you see entries like stash@{0}: WIP on main: abc1234 commit message, then stashes exist and the error might be from a different issue.
You can also check the total count:
# Count stash entries
git stash list | wc -lIf you previously ran git stash pop successfully, the stash would have been applied AND removed. The changes should now be in your working directory.
# Check for uncommitted changes in working directory
git status
# View recent changes
git diffIf you see your previously stashed changes here, you're all set - the stash worked! The "No stash entries found" error on a subsequent pop is expected because the stash was already consumed.
Tip: Use git stash apply instead of git stash pop if you want to keep the stash entry after applying. This allows you to re-apply the same stash multiple times.
If a stash was accidentally dropped or cleared, you may be able to recover it if Git hasn't garbage collected it yet.
# Find unreachable stash commits
git fsck --unreachable | grep commit | cut -d' ' -f3 | xargs git log --merges --no-walk --grep=WIPOr use this more comprehensive command:
# Find all dangling commits (potential stashes)
git fsck --no-reflogs | grep commit | cut -d' ' -f3 | xargs git log --oneline --graph --decorateIf you find your stash commit, note the SHA hash and recover it:
# Apply the recovered stash directly
git stash apply <commit-hash>
# Or re-add it to the stash list
git update-ref refs/stash <commit-hash> --create-reflogNote: This only works if the stash hasn't been garbage collected. Git typically keeps unreachable objects for at least 2 weeks by default.
By default, git stash does NOT include untracked files. If your changes were in new files that weren't added to Git, they weren't stashed.
# Check for untracked files
git status --porcelain
# Look for files marked with '??' (untracked)
git status -uFor future stashes, include untracked files:
# Stash including untracked files
git stash -u
# or
git stash --include-untracked
# Stash including untracked AND ignored files
git stash -a
# or
git stash --allIf you lost untracked files, check if your editor has local history (VS Code has "Local History: Find Entry to Restore").
Stashes are repository-specific. If you have multiple Git repositories, make sure you're in the right one.
# Show the repository root directory
git rev-parse --show-toplevel
# Show your current directory
pwd
# Show the remote URL to verify the repository
git remote -vIf you created the stash in a different repository:
# Navigate to the correct repository
cd /path/to/correct/repo
# Now check for stashes
git stash listRemember: Stashes are local and do not transfer when you clone a repository or push to a remote.
The reflog tracks recent Git operations and might show what happened to your stash.
# View stash-related reflog entries
git reflog show stash
# View general reflog for recent operations
git reflog | head -20Look for entries like:
- stash@{0}: drop stash@{0}: ... - indicates stash was dropped
- stash@{0}: reset: ... - indicates stash was applied/popped
If you see when the stash was dropped, the commit hash might help recover it using the git fsck method from Step 3.
If you need to stash current changes and avoid this error in the future:
# Basic stash (tracked files only)
git stash
# Stash with a descriptive message
git stash save "WIP: feature description"
# or (newer syntax)
git stash push -m "WIP: feature description"
# Include untracked files
git stash -u -m "Including untracked files"
# Verify the stash was created
git stash listBest practices to avoid losing stashes:
1. Use git stash apply instead of git stash pop when testing
2. Give stashes descriptive messages with -m
3. Don't rely on stashes for long-term storage - commit to a branch instead
4. Regularly check git stash list to know what's stashed
How Git Stash Works Internally:
Git stash creates special commits that are not part of any branch. When you run git stash, Git creates:
1. A commit for the working directory state (your changes)
2. A commit for the index/staging area state
3. A merge commit combining both, referenced by refs/stash
The stash is stored as a reflog at .git/refs/stash and .git/logs/refs/stash. When you pop or drop a stash, the reference is updated but the commits remain in the object database until garbage collection.
Stash vs. Branch:
For changes you might need to keep for more than a day, consider using a branch instead:
# Instead of stash
git checkout -b wip/my-feature
git add .
git commit -m "WIP: work in progress"
# When ready to continue
git checkout wip/my-featureBranches are more visible, can be pushed to remotes, and are less likely to be accidentally lost.
Garbage Collection and Stash Recovery:
Dropped stashes become "dangling commits" and will eventually be garbage collected. The default expiry is:
- 30 days for unreachable objects in the reflog
- 2 weeks for other unreachable objects
You can extend this:
# Check GC settings
git config gc.reflogExpire
git config gc.reflogExpireUnreachable
# Prevent immediate GC of unreachable objects
git config gc.pruneExpire "30 days"Stash in Scripts and CI/CD:
When using stash in scripts, always check if there's something to stash first:
# Safe stash in scripts
if ! git diff --quiet || ! git diff --cached --quiet; then
git stash push -m "auto-stash"
STASHED=true
fi
# ... do work ...
# Safe pop
if [ "$STASHED" = true ]; then
git stash pop
fiMultiple Stashes:
You can have multiple stash entries:
# Apply a specific stash without removing it
git stash apply stash@{2}
# Drop a specific stash
git stash drop stash@{1}
# Create a branch from a stash
git stash branch new-branch-name stash@{0}The index stash@{0} is always the most recent stash. Each new stash pushes older ones down the stack.
warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server