Git push to remote on network drive fails. But not always

68 views Asked by At

I created a bare repository set up on a network drive using this answer. (git init --bare on the network drive folder.) Creating new branches on the remote works fine but once I try to push changes I get:

> git push -u server main
remote: error: couldn't set 'refs/heads/main'        
To file://***MASKED PATH***
 ! [remote rejected] main -> main (failed to update ref)
error: failed to push some refs to 'file://***MASKED PATH***'

I use the VSCode extension which works wonderfully until I get to the Sync Changes (push) stage. If I instead try to do the push via Git GUI, I get the same error but with a prompt to try again. enter image description here

After clicking try again 10-20 times the push is finally successful...

I have tried the following suggestions in this answer and this answer:

  • HEAD: the .git/HEAD exists
  • privileges: I have checked privileges on the network folder and it's set to Full Control for Everyone. A few other groups also exists which all have Full Control EXCEPT the "guest( Unix User\guest)" which has no access.
  • multiple processes: Only VSCode or Git GUI is running at the same time. Not both, or any other program running git. I'm not sure how to check if multiple processes of the same program tries to access the file at the same time.
  • unpackLimit: I have set transfer.unpackLimit on the remote repository to 1
  • admin: I have run both VSCode, Git GUI and GIT CMD (only one at a time) as admin but the error remains.
  • shared: I have tried a new init with option --shared on the network drive.

When doing the same thing with git init --bare --shared the error is the same but the error message looks different:

> git push -u origin main
error: unable to write file ./objects/pack/pack-8975de7aa0b2dd6c527a0605420699a2b3b3c0f0.pack: Permission denied
error: unable to write file ./objects/pack/pack-8975de7aa0b2dd6c527a0605420699a2b3b3c0f0.idx: Permission denied
To file://***MASKED PATH***
 ! [remote rejected] main -> main (unable to migrate objects to permanent storage)
error: failed to push some refs to 'file://***MASKED PATH***'
0

There are 0 answers