Search code examples
gitmacosterminalfile-permissions

Git return "Permission Denied" when trying to add files


I recently bought a new mac, and have been cloning my repositories to it. I made a change to one of them, and tried to run git add --all, and was pretty surprised when git returned. [...] being the path to the repo locally. fatal: Unable to create '[...]/.git/index.lock': Permission denied

I pretty sure I ran git clone as the user that i'm currently logged in as.

Can someone tell me why this happened? why do i now have permission to the .git/index.lock file?


Solution

  • Seems I was wrong, seems I ran git clone with sudo. Removing the repository and cloning it again fixed the problem.