1

I just booted my Windows 10 machine for the first time in two or three months and updated a game whose versions I'm keeping in a git repo. There was a patch to the game, so I tried to stage the changes and got this error:

error: insufficient permission for adding an object to repository database .git/objects

I haven't changed anything since it worked a few months ago. ls -l in git bash shows me as the owner of all the files in the game directory. I can move and rename the files there. I'm also the owner of all the directories under .git/objects. What permission is git lacking?

More info

The structure of the path to the repo is C:\Program Files (x86)\Foo\Bar\.git. I previously ran chown -R Kevin . and chown -R Kevin .git inside Bar.

I can copy the Bar folder to my desktop. But copying Bar within Foo or Foo within C:\Program Files (x86) requires admin privileges.

This doesn't seem to explain what permission git needs. It should only write to the .git directory, right? And the error is from attempting to write files within .git. I can touch files there without any issue.

4
  • So is this Git repository entirely stored on one NTFS volume? Does it have free space? Have you tried running chkdsk yet?
    – Daniel B
    Jan 11, 2022 at 8:26
  • Try to copy the local folder to a new folder, deleting the old one, and renaming the new one to the old name.
    – harrymc
    Jan 11, 2022 at 8:41
  • @DanielB Yes; yes, 97GB; now I have, with no problems found. Jan 14, 2022 at 1:55
  • @harrymc Added more info. Jan 14, 2022 at 2:15

2 Answers 2

1
+50

Writing to C:\Program Files (x86) requires administrator permissions from Windows. To Windows, it doesn't matter that ls -lt in git bash shows you as the owner of the folder, and this doesn't get you any extra permissions from Windows on the folder.

I suggest to move the repository outside of C:\Program Files (x86), to avoid permission problems.

You may create the repository inside any folder by using git init inside that folder. You can turn any directory into a git repository this way just by using the git init command.

This will avoid permission problems on the folder of the repository.

For more information see the article Creating Local Repositories.

0

There could be some files with different permissions in a subdirectory.

You will need to change the directory ownership as mentioned in this Stackoverflow Answer.

2
  • How applicable is that answer to Windows 10? For example, what would I use for groupname in sudo chgrp -R groupname .? Jan 9, 2022 at 1:00
  • @Kevin: If you're on Win10 (assuming you mean Git for Windows, and not WSL) then you should inspect the Windows file permissions first, using icacls etc., not the emulated Unix ones... Jan 14, 2022 at 5:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .