File ownership/group is changed when users push to a GIT repository

廉价感情. 提交于 2019-11-29 12:01:51

问题


For over a year, I've been having troubles with GIT and directory/file permissions. I have a central repository to which multiple developers push code, using ssh (origin set up as ssh://example/git/repository). I have set up the repository as follows:

1) My config file in the central repository: [core] repositoryformatversion = 0 filemode = true bare = true sharedrepository = 0660

2) All repository directory permissions are set to 770 (rwxrwx---) 3) All files in ./objects/XX and ./objects/info are set to 440 (r--r-----) 4) All other files are set to 660 (rw-rw----) 5) Ownership is set to root:group_name

(note that this came from the reccomended setup in the top response in this thread: Making git push respect permissions?)

All accessing users are members of the group 'group_name'.

The problem is that if user1 pushes to the repository, the file ownership on some files are set to user1:user1 - meaning that the group is changed. Once this happens, no other users can push (or pull) from the repository, as they do not have permission to read, write or execute from required files in the repository anymore.

I have read every thread I can find regarding the matter on Stack Overflow and pretty much everywhere else on the net, but I keep running into this same issue.

The problem is, I'm not sure if this issue is one of GIT, or one of UNIX, and I'm not sure how to fix it. How can I stop the group from being changed when a user pushes to the repository?


回答1:


It looks like you changed the core.sharedRepository after initializing the repository rather than using init --shared=group which should set the permissions up correctly. This means that the sgid bit won't be set on the git repository's directories correctly. You will have to fix this manually with something like (assuming GNU find and xargs):

find . -print0 | xargs -0 chgrp group_name

find . -type d -print0 | xargs -0 chmod g+s


来源:https://stackoverflow.com/questions/16183345/file-ownership-group-is-changed-when-users-push-to-a-git-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!