"permission denied" while removing git directory

Try to delete the folder after closing any of the IDEs you are using (Eg: Aptana Studio). When you have this project opened in an IDE, it won't allow you to delete the git heads.


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

Windows 7 - Git-bash

$ sudo
sh.exe": sudo: command not found

git-bash in windows does not have sudo command.

Most probably, you used some git commands in command shell with elevated privileges. In windows 7 , your normal user and your user with elevated privileges have different powers. Try to do one of the following

  1. Try remove that directory in windows explorer
  2. Start git bash as administrator and run your rm command.
  3. Try to change its permissions so that your normal user has full control of that directory.

In PowerShell

rmdir <foldername> -force

Answer [A] to Yes to All