本文介绍了当用户推送到GIT存储库时,文件所有权/组会发生更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一年多来,我一直在使用GIT和目录/文件权限。我有一个中央存储库,多个开发人员使用ssh(起源设置为ssh:// example / git / repository)向其中推送代码。我已经建立了如下仓库:
$ b $ 1)我在中央仓库中的配置文件:
[core]
repositoryformatversion = 0
filemode = true
bare = true
sharedrepository = 0660
$ b 2)所有版本库目录权限设置为770(rwxrwx ---)
3)./objects/XX和./objects/info中的所有文件都设置为440(r - r -----)
4)所有其他文件都设置为660(rw -rw ----)
5)所有权设置为root:group_name



(请注意,这是来自此顶级响应中的reccomended设置线程:)



所有访问用户都是group_name组的成员。



问题是,如果user1压入存储库,某些文件的文件所有权设置为user1:user1 - 表示该组已更改。一旦发生这种情况,没有其他用户可以从存储库中推送(或拉出),因为他们没有权限读取,写入或从存储库中的所需文件执行。



我已经阅读了关于Stack Overflow和网上其他任何地方的每一个线索,但我仍然遇到同样的问题。



问题是,我不确定这个问题是GIT还是UNIX之一,我不知道如何解决这个问题。如何在用户推送到存储库时阻止组更改?

解决方案

它看起来像您更改了 core.sharedRepository 在初始化存储库之后,而不是使用 init --shared = group ,它应该正确设置权限。这意味着sgid位不会正确设置在git存储库的目录中。你将不得不手动修复这个(假设GNU find和xargs):

  find。 -print0 | xargs -0 chgrp group_name 

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


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?

解决方案

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

这篇关于当用户推送到GIT存储库时,文件所有权/组会发生更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 05:18