error: could not lock config file C:/Program Files/Git/mingw64/etc/gitconfig: Permission denied

Viewed 22907

I would like to run this Git command:

git submodule add https://github.com/example/example.git

But I get this error:

Cloning into 'C:/projects/xxx/yyy/zzz/'... fatal: unable to access 'https://github.com/xxx/yyy.git/': error setting certificate verify locations:
CAfile: C:\Program Files (x86)\git\bin\curl-ca-bundle.crt
CApath: none
fatal: clone of 'https://github.com/xxx/yyy.git' into submodule path 'C:/projects/xxx/yyy/zzz/example' failed

So, to fix this, I am trying to run this command:

git config --system http.sslcainfo "C:\Program Files (x86)\git\bin\curl-ca-bundle.crt"

But I get this error message:

error: could not lock config file C:/Program Files/Git/mingw64/etc/gitconfig: Permission denied

How can I fix this?

3 Answers

you need to be in admin mode to execute the command (in cmd terminal or in PowerShell (Admin) on windows10)

I had a similar problem, with Git Bash reporting the fatal "error setting certificate verify locations" for the git pull command. The actual problem turned out to be authentication, as I had recently changed my Windows password. The solution was to remove the git credentials in Credential Manager (Windows 7 | Control Panel | All Control Panel Items | Credential Manager), then try git pull twice to force Git Bash to supply the Windows popup prompting for the new password. No more certificate errors.

In the past after changing Windows password, we have only had to log out of BitBucket in order for Git Bash to initiate the Windows popup for entering the new password. This time the popup did not appear, and I started receiving the certificate error, so removing the credentials was the solution.

In my case, gitconfig was on another disk "D:\Program Files\Git\etc"

Edited the file "D:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\etc\gitconfig"

Changed the parameter

path = D:/Program Files/Git/etc/gitconfig
Related