Fix local changes would be overwritten by merge

Preserve uncommitted work before switching or pulling by committing, stashing, or moving changes—without deleting files to silence Git.

Updated Command scenarios locally verified

Git stopped because a merge, pull, or branch switch would replace files containing uncommitted work. This is a protective error. Do not bypass it by deleting or resetting files until you have reviewed the changes.

See exactly what needs protection

git status --short
git diff
git diff --cached

Include untracked files in your review. Then choose one of three safe routes.

Option 1: commit coherent work

git add path/to/file
git diff --cached
git commit -m "chore: save work before integration"

This is best when the change is meaningful and ready to record. You can refine the commit later according to your team’s workflow.

Option 2: stash unfinished work

git stash push -u -m "wip before pull"
git pull --ff-only
git stash apply

-u includes untracked files but not ignored files. Use apply first so the stash remains available until you verify the restored work. Resolve any conflicts, then drop the exact stash only after checking it.

Option 3: copy work outside the repository

For uncertain or valuable files, make an ordinary backup in a known directory outside the working tree before any recovery command. This is simple and independent of Git metadata.

High risk: git reset --hard, git checkout -- ., and git clean -fd can destroy local work. They are not required to resolve this error.

If you deliberately want to discard changes, first create a backup and list the exact affected paths. The Git undo cheat sheet organizes safer commands by whether work is committed, staged, or only in the working tree.

Sources and review

Last reviewed September 4, 2026. Technical claims are based on primary documentation and local command verification.