Git config command showing permission denied

Viewed 3259

I'm new to Git and repeatedly getting the following error.

When I type the command git config --global color.ui auto I get the error:

error: could not lock config file C:/Program Files/Java/jdk1.8.0_101/bin/.gitconfig: Permission denied

I have been getting the same permission denied error for other commands as well. I don't know if there is any problem with the path.

3 Answers

HOME should not be set to the JDK bin folder, but to your %USERPROFILE%.

Do check in a CMD session the value of your account:

set USER

You should see your username and USERPROFILE folder.

Then try the same git config command, in that CMD session, setting HOME first:

set HOME=%USERPROFILE%

I was facing permission denied for git config --global user.name command from Git bash in Windows.

I ran the Git bash with Administrator privileges and was able to resolve the error.

Note: I also got the same error from Intellij trying to commit changes; that too got resolved after running Intellij in Admin mode.

I had the same issue, trying to set the initial configuration for git - user.name and user.email and failing with a "Permission denied" error. It failed in Normal and Administrator mode and on all CLIs - PowerShell, CMD and GitBash.

The reason in my case was rather stupid. Somehow I had a ~/.gitconfig folder, rather than a file, so the CLIs were failing to create the file, due to filename conflict. Although the error message could have been more helpful.

The solution - just delete the folder and try again.

Related