Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git tries to delete a directory on checkout

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.

like image 961
user429400 Avatar asked Aug 12 '12 16:08

user429400


People also ask

Does git checkout delete local files?

git checkout does not affect untracked files. Git only manages tracked files, and it works fairly hard to avoid letting you lose data (which is critical).

Does git checkout change working directory?

Git Checkout File Checking out a file is similar to using git reset with a file path, except it updates the working directory instead of the stage. Unlike the commit-level version of this command, this does not move the HEAD reference, which means that you won't switch branches.

How do I remove a directory in git?

Just run the rm command with the -f and -r switch to recursively remove the . git folder and all of the files and folders it contains. This Git repo remove command also allows you to delete the Git repo while allowing all of the other files and folder to remain untouched.

How do I remove a directory in git bash?

Delete a Directory ( rm -r ) To delete (i.e. remove) a directory and all the sub-directories and files that it contains, navigate to its parent directory, and then use the command rm -r followed by the name of the directory you want to delete (e.g. rm -r directory-name ).


2 Answers

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.

like image 145
VonC Avatar answered Sep 19 '22 06:09

VonC


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

like image 44
Vincent Caruso Avatar answered Sep 22 '22 06:09

Vincent Caruso