8

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 
8
  • 2
    What is your current working directory? C:\Users\<username>? I'm afraid you are using Git command on a wrong path for a long time... Commented Dec 26, 2018 at 12:24
  • @GenoChen It must be like that %UserProfile% Commented Dec 26, 2018 at 12:28
  • @iBug Agree. These folder are likely a home directory under Windows. Commented Dec 26, 2018 at 12:41
  • @GenoChen Many thanks for your response /c/Users/Mateo Commented Dec 26, 2018 at 19:45
  • @MateoChiyangi That's it. Why you execute Git command on this path...? Commented Dec 26, 2018 at 20:56

4 Answers 4

12

In case someone else comes here when searching for this error, and they are definitely on the correct path already, this issue may be caused by unsaved files in the working directory - try making sure all files are saved, and closing any IDE that is open

Sign up to request clarification or add additional context in comments.

1 Comment

"Try making sure all files are saved, and closing any IDE that is open." - This helped. I had a file open in my text comparing tool. Thank you!
2

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.

1 Comment

Many thanks for your detailed response. How do I make sure I'm in the right directory?
0

I solve the same problem only get root access running the terminal as a administrator.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
-1
  1. First Go to that path and DELETE the .git repository.(In your File Manager)
  2. Open Git Bash at Required Folder(It means in Folder by clicking right click)
  3. Create .git repository by giving command ($ git init).
  4. By this there is one .git file will be created (.git file will created in your required folder).
  5. Now Check git status. Hurrrrrrrrrrayyyyy!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.