How to fix Cannot apply stash: Your local changes would be overwritten in Git

GitBEGINNERLOWUpdated Dec 6, 2025ยท 223 views

This error occurs when Git cannot cleanly apply stashed changes because files in your working directory have been modified since you created the stash. You need to either commit, stash, or discard your current changes before applying the original stash.

Quick fix

Fixes Cannot apply stash: Your local changes would be overwritten

git status
  1. Check which files are conflicting
  2. Option A: Stage your current changes first
  3. Option B: Stash current changes, then apply the older stash
  4. Option C: Commit your current changes
git โ€” error
git status
Cannot apply stash: Your local changes would be overwritten

What this error means

When you run `git stash apply` or `git stash pop`, Git attempts to merge your stashed changes with your current working directory. If you've made changes to the same files that exist in the stash since creating it, Git cannot safely apply those stashed changes without potentially losing your current work. This is a protective mechanism. Git refuses to overwrite your uncommitted modifications rather than silently destroying your work. The stash itself remains intact and can be applied once you resolve the conflict between your current changes and the stashed changes. This commonly happens when: - You stash work, switch branches to fix something, make changes to the same files, then try to pop the stash - You stash changes, continue working on the same branch, then forget you have unstaged modifications - Multiple team members work on the same files and you stash frequently

Typical symptoms

  • git stash pop or git stash apply fails with 'local changes would be overwritten' message
  • Error mentions specific files that would be overwritten
  • The stash is not removed from the stash list after a failed pop attempt
  • Working directory has uncommitted changes that conflict with stashed content
  • git status shows modified files that are also present in the stash

Common causes

  1. You have uncommitted changes in files that the stash also modifies (most common)
  2. You made changes after creating the stash to the same files
  3. The branch has evolved significantly since the stash was created, causing merge conflicts
  4. Untracked files in your working directory have the same names as files in the stash
  5. You're trying to apply a stash from a different branch with divergent file changes

How to fix "Cannot apply stash: Your local changes would be overwritten"

1Check which files are conflicting

First, identify what's causing the conflict. Check your current modifications:

bash
git status

Then see what files are in the stash:

bash
git stash show

Files appearing in both outputs are the source of the conflict.

2Option A: Stage your current changes first

The simplest fix is to stage your current changes, which clears the working tree conflict:

bash
git add .
git stash pop

After applying the stash, you can unstage everything if needed:

bash
git reset HEAD

This approach keeps both your current changes and stashed changes, though you may need to resolve merge conflicts in the files.

3Option B: Stash current changes, then apply the older stash

If you want to keep your current changes separate, create a new stash first:

bash
git stash push -m "current work in progress"
git stash pop stash@{1}

The original stash is now at position stash@{1} because the new stash took position stash@{0}. You can later apply the newer stash when ready.

4Option C: Commit your current changes

If your current changes are complete enough to commit:

bash
git add .
git commit -m "WIP: save current progress"
git stash pop

After applying the stash, you can amend the commit or continue working. If the stash creates conflicts, resolve them and commit.

5Option D: Discard current changes (use with caution)

If you don't need your current changes and want to apply the stash instead:

bash
git checkout .
git stash pop

Warning: This permanently discards all uncommitted changes. Make sure you don't need them before running this command.

6Option E: Force apply using patch method

For complex cases where nothing else works, you can force-apply the stash as a patch:

bash
git stash show -p | git apply

This applies the stash changes on top of your current changes. If there are conflicts, the patch will fail for those specific hunks, allowing you to manually resolve them.

To include untracked files from the stash:

bash
git stash show -p --include-untracked | git apply
7Option F: Create a branch from the stash

For stashes that are significantly different from your current state, create a new branch:

bash
git stash branch new-feature-branch

This creates a new branch from the commit where the stash was originally made, applies the stash, and drops it if successful. You can then merge this branch into your current work.

Advanced notes

### Understanding Stash Internals

A Git stash is actually a special commit that stores:
1. The state of your working directory
2. The state of your staging area (index)
3. Optionally, untracked files (with -u) or all files including ignored ones (with -a)

When you apply a stash, Git performs a three-way merge between the stash commit, the original parent commit, and your current HEAD. This is why conflicts can occur.

### Viewing Stash Contents Without Applying

To safely inspect what a stash contains before applying:

bash
# Summary of changed files
git stash show stash@{0}

# Full diff of all changes
git stash show -p stash@{0}

# Show untracked files too
git stash show -p --include-untracked stash@{0}

### Selective Stash Application

Instead of applying the entire stash, you can checkout individual files:

bash
git checkout stash@{0} -- path/to/specific/file.js

Warning: This overwrites your current version of that file with the stashed version without attempting a merge.

### Git Stash Pop vs Apply

- git stash pop: Applies the stash and removes it from the stash list (if successful)
- git stash apply: Applies the stash but keeps it in the stash list

When conflicts occur with pop, the stash is NOT removed. You must manually run git stash drop after resolving conflicts if you want to remove it.

### Preventing Future Issues

Consider these practices to avoid stash conflicts:

1. Use descriptive stash messages:

bash
git stash push -m "feature X: partial login form"

2. List stashes before applying:

bash
git stash list

3. Apply stashes promptly - the longer a stash sits, the more likely conflicts become

4. Consider feature branches instead - for longer-term work storage, a branch is often more appropriate than a stash

Frequently asked questions

What does "Cannot apply stash: Your local changes would be overwritten" mean?
When you run git stash apply or git stash pop, Git attempts to merge your stashed changes with your current working directory. If you've made changes to the same files that exist in the stash since creating it, Git cannot safely apply those stashed changes without potentially losing your current work. This is a protective mechanism.
How do I fix "Cannot apply stash: Your local changes would be overwritten"?
This error occurs when Git cannot cleanly apply stashed changes because files in your working directory have been modified since you created the stash. You need to either commit, stash, or discard your current changes before applying the original stash.
What causes "Cannot apply stash: Your local changes would be overwritten"?
You have uncommitted changes in files that the stash also modifies (most common) You made changes after creating the stash to the same files The branch has evolved significantly since the stash was created, causing merge conflicts
Is the "Cannot apply stash: Your local changes would be overwritten" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading