`git switch release` fails with `error: The following untracked working tree files would be overwritten by checkout:` followed by `Please move or remove them before you switch branches.`
IntermediateTroubleshootingConfig, Line Endings, Files and Platform Quirks
Answer
Likely causes → Files that are untracked on your current branch are tracked on the target branch (for example, a generated config.json or a file you created that someone else committed there). Git will not destroy untracked data silently.
Diagnose →
git status --short --untracked-files=all | grep '^??'
git diff --stat HEAD release -- config.json
Fix → Keep your copy if it matters, then switch:
mv config.json /tmp/config.json.mine # or: git stash push --include-untracked
git switch release
diff /tmp/config.json.mine config.json
To discard instead: git clean -n to preview, then git clean -f config.json, or git switch --discard-changes release, which overwrites untracked files in the way (they are lost).
Prevent → Ignore generated files consistently on all branches, and don't commit files that the build generates.
More on Config, Line Endings, Files and Platform Quirks
`warning: in the working copy of 'app.sh', LF will be replaced by CRLF the next time Git touches it`Beginner`git diff` shows `old mode 100755` / `new mode 100644` for hundreds of files with no content change.BeginnerCloning on Windows fails with `error: unable to create file src/very/deep/.../component.test.ts: Filename too long`.BeginnerYou renamed `header.tsx` to `Header.tsx` on macOS. Locally everything builds, but Linux CI fails with `Module not found: Can't resolve './components/Header'`.IntermediateCheckout on Windows fails with `error: invalid path 'logs/2024-01-01T10:00:00.log'` (or `'docs/aux.md'`) and `fatal: unable to checkout working tree`.IntermediateClone prints `warning: the following paths have collided (e.g. case-sensitive paths on a case-insensitive filesystem) and only one from the same colliding group is in the working tree:`Intermediate