2

I came across git error

unable to write sha1 filename 
.git/objects/42/e819f886bf31b67c42249a0eff8e8b16cf7611: Permission denied.

This happens each time I pull Git repos and modify some of my colleague's files, then push them to origin master. My colleague has the same error if do my way. I tried to init git repos, but the error happen again with above action. (This error never happened before).

I also tried other ways as members suggest here, like change auth to 777, or open git bash with admin identity, but all in vain. We use TortoiseGit, and git server is built on NAS Synology.

halfer
  • 19,824
  • 17
  • 99
  • 186
Z. Lary
  • 41
  • 1
  • 3
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Jul 30 '17 at 17:46
  • I believe that a Git server runs under your own username via SSH, so try SSHing into the server to get a shell, and then try to write a file `touch .git/objects/foo` under your user account. Does this create? Delete it if so. If not, what user/group ownership do these files have? You may have to reset your file/dir permissions, users or groups using `chmod` or `chown`, and the exact sequence of commands required depends on a lot of things. Perms of `777` may not be any good if the user/group on those files is not related to your user. – halfer Jul 30 '17 at 17:51
  • https://stackoverflow.com/a/22106970/6309 might help? – VonC Jul 31 '17 at 04:57

1 Answers1

0

I solved this problem in the following way: The user on the git server has not only to be a member of the group git - assuming git is the user on the server owning the repositories - they have also be a member of the group of each other user commiting to the repository.

This is because the folders under "objects" are owned by the first who needs them. After a while it may happen that such a folder may be reused by another user. If the other user is not member of the group who initially created that folder they may be refused to do anything with that folders.

Folders below objects are named with 2 hex letters, from 01 to fa - in my case.

ngong
  • 754
  • 1
  • 8
  • 23
  • assume users A and B are pushing to the same repository. User A indirectly creates randomly folder objects/a1, B objects/ef. After a while A randomly has to use objects/ef. Therefore A has to be a member of group B otherwise the "unable to migrate objects ..." happens. – ngong Nov 27 '20 at 07:28