Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"permission denied" while removing git directory

I'm trying to remove a .git directory while using win7 and git-bash. here's my attempt:

$ rm -rf .git
rm: cannot remove directory `.git/objects/5e': Permission denied
rm: cannot remove directory `.git/objects': Directory not empty
rm: cannot remove directory `.git': Directory not empty    

$ rmdir .git
rmdir: `.git': Directory not empty

What am I doing wrong?

like image 981
user1592380 Avatar asked Dec 21 '14 14:12

user1592380


People also ask

How do I completely 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 delete a directory in Terminal Permission denied?

Open the Terminal on Linux and execute sudo su to access Root, then type your root password and press Enter. On Linux, you can use the ls command to display the directory in your current location. To delete the undeleted folder, execute rm -rf vmware-tools-distrib.

Why do I get permission denied in git bash?

If you get the error "Permission denied", it is also possible that git doesn't have permission to create the project folder locally. Check permissions for the directory where you're attempting to check out the project, and make sure you have write access.

How do I remove permissions from a directory in Linux?

To remove world read permission from a file you would type chmod o-r [filename]. To remove group read and execute permission while adding the same permission to world you would type chmod g-rx,o+rx [filename]. To remove all permissions for group and world you would type chmod go= [filename].


1 Answers

I faced with similar problem. It turns out that git makes certain files (objects) read only. So you need to remove read-only flag recursively and then remove folder:

chmod -R a+w .git
rm -rf .git
like image 126
Gilo Agilo Avatar answered Sep 17 '22 18:09

Gilo Agilo