git tries to delete a directory on checkout

user429400 picture user429400 · Aug 12, 2012 · Viewed 10k times · Source

Whenever I switch between my branch (Li) to the master branch I get the following message:

Deletion of directory 'sys/console/api' failed. Should I try again? (y/n)

Anyone knows how do I get rid of this message? I think that in the past I tried to delete this directory by mistake and now I'm stuck with this error message.

Answer

VonC picture VonC · Aug 12, 2012

This error message comes from this patch (in compat/mingw.c), and this one (also in compat/mingw.c).
It usually means your directory is "busy", or isn't empty (but contains only private files, ie non-versioned files).

So make sure that, when checking out a branch, you don't have a running process making your specific directory "busy".

Ted M Young helpfully comments:

Another definition of "busy" is that it's your current directory!
It seems safest to do a cd to the root directory and then change directories to avoid this error.