18

I am a beginner. I try to use git to create the user's name. but when I typed

git config --global user.name "XXX"

the message shows

Unable to read current working directory: Operation not permitted.

I don't know what happened. How can I fix this problem?

mybrave
  • 1,662
  • 3
  • 20
  • 37
Joanne Wei
  • 201
  • 1
  • 2
  • 4
  • Does this answer your question? [fatal: Unable to read current working directory: No such file or directory](https://stackoverflow.com/questions/48293849/fatal-unable-to-read-current-working-directory-no-such-file-or-directory) – Hareen Laks Apr 12 '20 at 07:01

2 Answers2

70

I had a similar problem after updating to MacOS Catalina 10.15 and updating Xcode Command-line Tools (xcode-select --install).

I received the above error when simply trying to do git status. Then noticed I couldn't even do ls. Apparently it's necessary grant Terminal, or iTerm in my case, "Full Disk Access".

  1. Go to System Preferences -> Security & Privacy -> Privacy tab
  2. Select "Full Disk Access" from the left-side menu
  3. Add Terminal and/or iTerm to the app list

See this article for more details: https://osxdaily.com/2018/10/09/fix-operation-not-permitted-terminal-error-macos/

UPDATE - 1/2023: I recently updated to MacOS Ventura 13.1 and ran into the same issue. Running xcode-select --install did the trick for me. Another helpful article.

kenecaswell
  • 7,212
  • 1
  • 24
  • 19
1

Check your home directory and .gitconfig file permissions using ls -l command. If all is ok try to use sudo chattr -i .gitconfig to check immutable attribute on this file.

You can find details about this command and file attributes here.

ceth
  • 44,198
  • 62
  • 180
  • 289