# error: Your local changes to the following files would be overwritten by checkout

**Code:** `overwritten by checkout` · **Category:** Git · **Seen on:** Git

Switching branches would discard uncommitted changes in files that differ between branches.

## 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

1. Commit or stash: git stash && git switch other && git stash pop
2. Or carry changes with git switch --merge (careful)

## Detailed fix by platform

### Git

1. `git stash push -m "wip" && git switch release && git stash pop`

## How to diagnose

1. **Files** — Which ones are listed?
2. **Recent change** — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/git/would-be-overwritten-by-checkout)
