Common causes
- You edited files that exist differently on the target branch
- You forgot to commit work-in-progress before switching context
- A save or auto-format tool modified tracked files
- You modified a file that was deleted or renamed in the target branch
How to fix it
- Commit the changes: git add . && git commit -m 'WIP'
- Or stash them: git stash, switch branches, then git stash pop when you return
- Discard the changes if they don't matter: git checkout -- <file> or git restore <file>
- Use git status to review exactly which files are affected before deciding
Example
error: Your local changes to the following files would be overwritten by checkout:
src/config.js
Please commit your changes or stash them before you switch branches.Running git checkout <other-branch> with uncommitted changes
Have a different error?
Paste any error message into the Error Translator to get an instant explanation.
