error: The following untracked working tree files would be overwritten by checkout

randomor picture randomor · Aug 19, 2014 · Viewed 80.7k times · Source

When I do git status it says nothing to commit, working directory clean

And then I do git pull --rebase, it says:

First, rewinding head to replay your work on top of it...
error: The following untracked working tree files would be overwritten by checkout:
    includes/resources/moduledata/12/_Fr4_02_Invention_IPA_SR_la-Fête.pdf
Please move or remove them before you can switch branches.
Aborting
could not detach HEAD

Similar error when doing git pull origin master

 * branch            master     -> FETCH_HEAD
error: The following untracked working tree files would be overwritten by merge:
    includes/resources/moduledata/12/_Fr4_02_Invention_IPA_SR_la-Fête.pdf
Please move or remove them before you can merge.
Aborting

My .gitignore file:

→ cat .gitignore 
.htaccess
bower_components/

This file has been coming up constantly and when I remove it from file system, git will say I removed this file, while in the other messages, it says it is untracked. How could it be untracked and tracked at the same time?

Answer

MikeHall picture MikeHall · May 13, 2015

This could also happen due to a case change on the filename. I had the same problem and this is what solved it for me.

git config core.ignorecase true

True for Mac or PC.

Alternative solutions at: The following untracked working tree files would be overwritten by checkout