我正在使用Windows10。当我键入命令“ git add”时。在我的Git Bash中,我不断收到此消息,如下所示:
warning: could not open directory 'AppData/Local/Application Data/': Permission denied
warning: could not open directory 'AppData/Local/ElevatedDiagnostics/': Permission denied
warning: could not open directory 'AppData/Local/History/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Content.IE5/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/Temporary Internet Files/': Permission denied
warning: could not open directory 'AppData/Local/Temporary Internet Files/': Permission denied
warning: could not open directory 'Application Data/': Permission denied
warning: could not open directory 'Cookies/': Permission denied
warning: could not open directory 'Documents/My Music/': Permission denied
warning: could not open directory 'Documents/My Pictures/': Permission denied
warning: could not open directory 'Documents/My Videos/': Permission denied
warning: could not open directory 'Local Settings/': Permission denied
warning: could not open directory 'My Documents/': Permission denied
warning: could not open directory 'NetHood/': Permission denied
warning: could not open directory 'PrintHood/': Permission denied
warning: could not open directory 'Recent/': Permission denied
warning: could not open directory 'SendTo/': Permission denied
warning: could not open directory 'Start Menu/': Permission denied
warning: could not open directory 'Templates/': Permission denied
答案 0 :(得分:5)
如果搜索此错误时有人来这里,并且他们已经确定在正确的路径上,则此问题可能是由于工作目录中未保存的文件引起的-请尝试确保所有文件保存,并关闭所有打开的IDE
答案 1 :(得分:2)
您正在意外目录上运行Git子命令。
大多数Git子命令与路径有关。在大多数情况下,这些子命令将当前工作目录视为Git根目录,并在内部 Git根目录中执行Git操作。
对于常规用法,我们将代码项目的根目录视为Git根目录。多个代码项目导致多个文件夹和多个对应的Git根目录。使用当前工作目录进行指定。
默认的当前工作目录称为主目录,在* nix中为~
或大部分为/home/<user>
或/root
,或者为C:\Users\<user>
(非管理员)或{在Windows> 7中为{1}}(管理员),在Windows <= XP中为C:\Windows\System32
。
如果未指定当前工作目录(使用命令C:\Documents and Settings\<user>
),则所有Git操作都在操作您的主目录。在某些情况下这可能是有害的。小灾难就像遇到的一样,大灾难可能是您无意中将私有文件上传到GitHub或类似的事情,而您意识到了这一点。