Interview Prep/Git & GitHub/Config, Line Endings, Files and Platform Quirks

`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.

All Git & GitHub questions Roadmap: Git & GitHub

More on Config, Line Endings, Files and Platform Quirks