error: Your local changes to the following files would be overwritten by checkout
Switching branches would discard uncommitted changes in files that differ between branches.
Seen on:
Git
Meaning
Commit, stash or discard first. git switch refuses for the same reason.
Common causes
- Uncommitted changes to files that differ on the target branch
- Generated/build files that are tracked in git
⚡ Quick fix
- Commit or stash: git stash && git switch other && git stash pop
- Or carry changes with git switch --merge (careful)
Detailed fix by platform
Git
git stash push -m "wip" && git switch release && git stash pop
How to diagnose
- Files — Which ones are listed?
- Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026