Windows &引用;“拒绝许可”;删除git目录时

Windows &引用;“拒绝许可”;删除git目录时,windows,git,git-bash,Windows,Git,Git Bash,我试图在使用win7和git bash时删除.git目录。以下是我的尝试: $ 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

我试图在使用win7和git bash时删除.git目录。以下是我的尝试:

$ 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
我做错了什么?

Windows7-GitBash

$ sudo
sh.exe": sudo: command not found
windows中的git bash没有sudo命令

最可能的情况是,您在命令shell中使用了一些具有提升权限的git命令。在windows 7中,普通用户和具有提升权限的用户具有不同的权限。尝试执行以下操作之一

  • 尝试在windows资源管理器中删除该目录
  • 以管理员身份启动gitbash并运行rm命令
  • 尝试更改其权限,以便普通用户完全控制该目录
    尝试在关闭您正在使用的任何IDE(例如:Aptana Studio)后删除该文件夹。当您在IDE中打开此项目时,它将不允许您删除git头。

    我面临类似的问题。事实证明,git使某些文件(对象)成为只读的。 因此,您需要递归删除只读标志,然后删除文件夹:

    chmod -R a+w .git
    rm -rf .git
    
    在PowerShell中

    rmdir <foldername> -force
    
    rmdir-force
    

    答[A]全部为“是”

    我最后使用选项1:控制面板>文件夹选项>视图选项卡>检查显示隐藏文件文件夹和驱动器。在我的情况下,我有一个目录打开的git客户端(GitKraken),所以在我关闭它之前,它不允许我删除。