BugMedic

Git “local changes would be overwritten”: stash before you pull

Save the uncommitted work first, then let Git update the branch.

By BugMedic editorial teamLast source review: 2026-09-27Windows, macOS, Linux

Commit or stash your uncommitted changes before pulling, merging, or switching branches. Git refuses the operation to avoid destroying work it cannot recover.

Try these fixes in order

01

Inspect what is uncommitted

Run git status to list modified and staged files, then git diff to review the actual edits. Knowing which changes are valuable determines whether to keep or discard them.

git status
git diff --stat
02

Stash or commit the work you want to keep

If the work should be kept, save it with git stash push -m "description" or commit it on the current branch. If some edits are disposable, discard only those paths with git restore <path>.

git stash push -m "work in progress"
03

Retry the pull, merge, or checkout

Re-run the original git pull, git merge, or git checkout. With the worktree clean relative to the incoming changes, the operation should proceed.

04

Restore the stash and resolve conflicts

Bring the stashed work back with git stash pop and resolve any conflicts it reports. Verify the files, run the project's checks, then commit so the work is no longer only in the stash.

git stash pop

Interpret what you see

The error names specific files you were editing

What it suggests: Git is protecting uncommitted edits from being silently replaced by incoming changes to the same files.

Next check: Run git status and git diff --stat to see exactly which files you have modified.

The error appears even though git diff shows nothing

What it suggests: Your worktree is clean but the index has staged changes that conflict with the incoming update.

Next check: Decide whether to commit the staged work or unstage it with git reset before proceeding.

You recognize some listed files as disposable

What it suggests: Only some listed files matter to you; the rest may be generated or incidental edits you can discard.

Next check: Use git checkout -- <path> or git restore <path> solely for files you are willing to lose, after confirming they hold nothing valuable.

Why this happens

  • Uncommitted edits touch the same files that the incoming pull, merge, or checkout would modify.
  • Work stayed uncommitted in the worktree for a long time while the branch moved forward elsewhere.

Still not working?

A stash is a real commit-like object, but it is easy to forget. If git stash pop reports conflicts, resolve them before dropping the stash, and confirm git stash list is empty only after the work is safely committed or the files verified.

Official sources

These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.

Related Git guides