I am using windows 10. When I type the command "git add ." in my Git Bash I keeping getting this message as shown below:
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
You are running Git subcommand on a unexpected directory.
Most of Git subcommand are path-dependent. In most cases these subcommand treats the current working directory as Git root, and do Git operations inside Git root.
For regular usage, we treat the root directory for code project as Git root. Multiple code project results in multiple folder, and multiple corresponding Git roots. Use current working directory to specify them.
The default current working directory is called Home directory, which is ~
or mostly /home/<user>
or /root
in *nix, or C:\Users\<user>
(non-Administrator) or C:\Windows\System32
(Administrator) in Windows > 7 or C:\Documents and Settings\<user>
in Windows <= XP.
If you didn't specify current working directory (with command cd
), all the Git operations are operating your home directory. This can be harmful under some situations. Small disaster is just like what you met, big disaster can be something like you accidently uploaded your private file in GitHub or something equivalent after you realized that.
来源:https://stackoverflow.com/questions/53932041/git-add-errors-could-not-open-directory-permission-denied