Common causes
- You created files locally that aren't tracked by Git but exist in the target branch
- You ran git clean to remove tracked files but the untracked replacements remain
- A previously generated artifact shares a name with a tracked file in the other branch
- Files were moved to .gitignore but still exist on disk
How to fix it
- Check what untracked files are present: git status
- Remove the conflicting untracked files if they're safe to delete: rm <filename>
- Or move them somewhere else temporarily before switching branches
- To force-overwrite (will lose the local untracked files): git checkout -f <branch>
Example
error: The following untracked working tree files would be overwritten by checkout:
dist/bundle.js
Please move or remove them before you switch branches.Switching to a branch that includes a file you also have as an untracked local file
Have a different error?
Paste any error message into the Error Translator to get an instant explanation.
