Git Gui on Windows: couldn't open ".git/PREPARE_COMMIT_MSG": permission denied

130 Views Asked by At

Been using Git Gui on Windows on a work computer for over two years now. Last night the repo was working fine, but this morning after a reboot, Git Gui pops up a message about "permission denied".

No idea what changed, although we did get an email saying that a corporate antivirus update had been pushed out which required a reboot. Also, a Windows update for December 2022 was installed on my machine which also required a reboot.

The full error message is:

couldn't open ".git/PREPARE_COMMIT_MSG": permission denied
couldn't open ".git/PREPARE_COMMIT_MSG": permission denied
    while executing
"open [gitdir PREPARE_COMMIT_MSG] a"
    (procedure "run_prepare_commit_msg_hook" line 8)
    invoked from within
"run_prepare_commit_msg_hook"
    (procedure "rescan" line 27)
    invoked from within
"rescan ui_ready"
    (procedure "do_rescan" line 2)
    invoked from within
"do_rescan"
    ("after" script)

Things I have tried:

  • Based on suggestions in threads with similar "permission denied" errors, I ran the follow from a command prompt:

    icacls "path\to\Work.git" /grant MyUserName:(OI)(CI)F /T

The command executed without errors, but no change to the repo.

  • Ran Git Bash (MINGW64) which runs without any immediate errors but only git status works. git add gives the error fatal: Unable to create '/path/to/Work/.git/index.lock': Permission denied

  • Tried a separate, personal, repo on the same work computer for a repo hosted on github.com. That worked fine (can commit, pull, etc.).

Any thoughts? My user account is part of the Administrators group, but it looks like the Windows and "corporate anti-virus" updates have modified or blocked something to do with my user account.

UPDATE 1

Rebooted Windows into Safe Mode. Now I can git add and git commit, though git push fails due to a failure to resolve dev.azure.com (something to do with the network not loaded in Safe Mode). Rebooted back into normal Windows and the problem returns: git add and other commands fail immediately and git push finds dev.azure.com but I get a permission denied error.

UPDATE 2

Based on the comments from @LeGEC, I checked the repo .git folder. There is no PREPRE_COMMIT_MESSAGE or index.lock file. The permissions haven't been touched by me, but after explicitly allowing my user "Full Control" over the folder, its still not working - still "permission denied" errors.

A colleague does not use Git for Windows, and was not having issues after the recent update. He suggested I try Visual Studio (which is tied directly into dev.azure.com)...and git works from Visual Studio 2019!

So we think that recent anti-virus or group policy changes has revoked, blocked or broken authentication of my user (presumably) connecting to the corporate network's and/or dev.azure.com. Somehow Visual Studio is able to authenticate me (through the Mcicrosoft Azure account?) which fails when using my Windows account....does that make sense?

Will update this question as and when I find out more details.

If anyone has seen this type of thing before (suddenly one application stops working with git with "permission denied" errors, while another works), your input would be appreciated!

0

There are 0 best solutions below