Can not switch git branch: "Untracked file" but working directory clean
git
Solution
You face the problem that the branch you want to check out contains numerous files like `foo.phtml` which are not tracked in your current branch. It seems that you can just delete the files, so try:
git checkout -f otherbranch
Problem
I want to switch the branch. but get the error ``` error: Untracked working tree file 'foo.phtml' would be overwritten by merge. ``` If I delete this file the next file is complained about. The problem is that there is a very vast difference of files in the two branches. This is what I tried: ``` $ git reset --hard HEAD HEAD is now at 8a2a95c Initial checkin $ git checkout otherbranch error: Untracked working tree file 'foo.phtml' would be overwritten by merge. $ git status # On branch master # Your branch and 'origin/master' have diverged, # and have 1 and 677 different commit(s) each, respectively. # nothing to commit (working directory clean) ``` What is wrong here? I also already tried ``` git clean -f -d ```