Your local changes would be overwritten by merge

Git is protecting uncommitted edits that collide with incoming commits. You must park, commit or discard those edits before the merge can proceed.

The exact error

error: Your local changes to the following files would be overwritten by merge:
        src/app.js
Please commit your changes or stash them before you merge.
Aborting

Variants mention checkout, rebase or pull instead of merge — same idea: Git will not silently trash your working tree.

What Git is protecting

You have modifications that are not committed. The branch you are merging (or the tip you are checking out) also changes those paths. Applying the other side would replace your file contents. Git stops instead of guessing.

Three safe exits

1. Commit your work (best if the edits belong on this branch)

git status
git add -p          # or git add path
git commit -m "WIP: describe the change"
git pull            # or git merge / git pull --rebase

If the pull then reports conflicts, that is a normal merge conflict — see merge conflict markers.

2. Stash, update, re-apply (best for “I am not ready to commit”)

git stash push -u -m "wip before pull"
git pull
git stash pop
# resolve any conflicts from the pop, then continue working

-u includes untracked files that would also be clobbered. List stashes with git stash list; drop with git stash drop only after you are sure.

3. Discard local edits (only if you truly do not need them)

git restore path/to/file          # modern
# or: git checkout -- path/to/file
git pull

Untracked files need git clean — that is destructive; preview with git clean -nd first.

Inspect before you choose

git status
git diff                  # unstaged
git diff --staged         # staged
git diff main -- path     # how your file differs from the branch you will merge

Compare two versions side by side in the text diff tool if you paste both copies. Check a downloaded archive matches with the hash generator.

Not the same as

Related

git merge conflict markers · git push rejected (non-fast-forward) · git divergent branches · detached HEAD · src refspec main does not match any · Text diff

Questions

What does “local changes would be overwritten by merge” mean?

You have uncommitted edits in files that the incoming merge would also change. Git aborts so it does not delete your work.

How do I fix it quickly?

Commit, or git stash -u, then pull/merge, then git stash pop. Only discard with git restore if you are sure.

Does git pull --force fix this?

No — and force on pull is dangerous. Park or commit local changes first.

Why stash -u?

Without -u, untracked files stay in the way and can still block checkout/merge.

I stashed and pop shows conflicts — did I break git?

No. Resolve the conflicted files, git add them, and continue. The stash entry may remain; drop it when done.

Is this a merge conflict?

Not yet. This error happens before the merge starts. Markers appear only after a merge with overlapping committed changes.

Published .

Try it

Related guides

Newest guides