Pushing to a Git repository on an NFS share fails

2020-03-27 08:25发布

We currently have our Git repositories on the local disk. They are shared by groups and accessed over SSH (with git-shell).

Because of space issues, we now want to move the repositories to an NFS share on a NAS. I've been experimenting with this, and have run into a weird issue. A fresh (and bare) repository with exactly the same permissions can be cloned fine, but pushing changes (touch foo && git add foo && git commit && git push origin master) fails with the error "Couldn't set refs/heads/master" and "failed to write".

Now, if I repeat this scenario on the local disk, refs/heads/master becomes owned by whatever user pushed. Conversely, on the NFS share, if I change its owner to the user who is trying to push, no error is thrown. However, in both cases, the user is a member of a the group that owns the entire repository and has group write permission. Additionally, if I just log in using SSH as a user who is a member of this group, I can touch refs/heads/master (as is to be expected), both on the NFS share and the local disk.

Consequently, I am at a loss here. I have no idea why a different file owner would cause the push to fail, seeing as how the group permissions allow the user to overwrite refs/heads/master. Moreover, even with a chmod 777 on that file, the push fails unless I chown the file.

If anyone can shed some light on this weirdness, I'll be most grateful. Thanks in advance!

标签: git ssh nfs
1条回答
疯言疯语
2楼-- · 2020-03-27 08:41

Ah, darn. The NAS is doing weird things to permissions, setting the sticky bit on all directories. This explains the behavior. An additional chmod solved the problem.

查看更多
登录 后发表回答