git tries to delete a directory on checkout
Asked Answered
P

4

38

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.

Pileus answered 12/8, 2012 at 16:7 Comment(0)
G
37

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.

Genni answered 12/8, 2012 at 17:21 Comment(6)
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.Islet
@TedM.Young good point. I have included your comment in the answer for more visibility.Genni
I went from scratching my head straight to a facepalm. Thanks @TedM.Young and VonCCanaveral
Could you please explain in words what it is the piece of code you have written in your answer does? (I am in no mood to try to interpret it and find out what it does, besides, this is a git question; I'm not even sure everyone who reads your answer knows how to interpret C code) In what way is it related to the rest of the answer?Messiaen
@Messiaen Sure. I have removed the code (now part of the Git compat/mingw.c source code). That code was just to illustrate where the error message "Deletion of directory '...' failed. Should I try again? (y/n)" comes from (the message that the OP mentions in the question). From a user's perspective, all you need to do is making sure your directory you want to delete isn't busy.Genni
I had my file opened in Sublime Text (my IDE.) Closing that out fixed the issue.Melicent
M
6

I just had to quit out of VS Code to get the error to go away

Mckenna answered 20/8, 2020 at 2:4 Comment(2)
You may have had a similar error message, but your answer might not be an answer to this question. The question is eight years old and doesn't mention VS Code.Pomeranian
That sucks when I'm running the command from inside vs codeLacasse
N
1

As with all the blocking Folder/File things, use Process Explorer → Ctrl + F → type the folder name. See the vscode, notepad++ or other app that is using it, kill the process.

Niobe answered 22/12, 2021 at 9:46 Comment(0)
S
0

Ensure that these directories are not tracked by sync programs like Google Drive / Microsoft OneDrive, or turn them off.

Swiss answered 18/7 at 14:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.