Home > Back-end >  Cannot remove .git/: Directory not empty
Cannot remove .git/: Directory not empty

Time:04-15

I have a .git/ folder that I'd like to delete. However, it isn't possible because there is a puzzling file into it which is not reachable.

Below is my try:

$ rm -rf .git/ 
rm: cannot remove '.git/': Directory not empty   
$ rm -r .git/
rm: descend into directory '.git/'? y
rm: cannot remove '.git/t8QVta1': No such file or directory
rm: remove directory '.git/'? y
rm: cannot remove '.git/': Directory not empty
$ ls -l .git/
ls: cannot access '.git/t8QVta1': No such file or directory
total 0
?????????? ? ? ? ?            ? t8QVta1
$

I have no idea what is the 't8QVta1' file and all of the question marks.

Many thanks for your help.

CodePudding user response:

The ?????????? ? ? ? ?... output of ls may indicate that you are missing the correct permissions to access this file. If this is the problem, you could try giving yourself permissions over the parent directory and its children with the following command:

sudo chmod -R g x .git/

CodePudding user response:

To remove a non-empty folder use -rf flags

$ rm -rf .git

  • Related