Git does not allow me to switch branches in a clean working directory. Instead it tells me a file in an ignored folder would be overridden.
$ git status
# On branch ECP-2229
nothing to commit (working directory clean)
$ git checkout ECP-2243
error: The following untracked working tree files would be overwritten by checkout:
c.t.e.server.logback/bin/logback.xml
Please move or remove them before you can switch branches.
Aborting
There are hundreds of files in this and other bin/ folders in this working directory, all of them ignored.
$ cat .gitignore
bin
I assumed that the file would be already tracked somehow and tried to remove it, but
$ git rm c.t.e.server.logback/bin/logback.xml
fatal: pathspec 'c.t.e.server.logback/bin/logback.xml' did not match any files
What is wrong with this file and how can I convince git that it does not matter?
For some reason someone tracked
logback.xml, and you have an untracked version of this file. So git warns you that your untracked version will be overwritten by checkout, which is good, even if it is in.gitignore(who knows it doesn’t contain value?).You fail to
git rmit because yours is untracked, so unknown to git,git rmonly works on tracked or staged files.Instead just
rmit and you’ll be fine.