linux - Git Windows 多用户 - 组权限问题

标签 linux windows git samba

我的客户端/服务器 git 配置有问题,当有多个用户推送更改时会产生权限问题。我的用户遇到错误:

remote: error: insufficient permission for adding an object to repository database ./objects

我的配置 git 存储库位于 NetApp 网络共享上。此网络共享安装在 Red Hat (RHEL) 6.4 Linux 服务器上。要创建存储库,用户登录到 RHEL 服务器,导航到他们想要存储库的位置(在挂载的共享上),然后运行命令:

git init --bare --shared=true repo.git

每个用户都在自己的 Windows 7/10 机器上本地工作,他们安装了 git windows,并且将前面提到的网络共享映射为驱动器。为了在他们的机器上获取存储库,他们打开 git-bash 并导航到他们想要在本地克隆存储库的位置。然后他们运行:

git clone Z:/git_repo_location/repo.git 

问题 用户能够将更改推送到存储库并且一切正常,直到他们尝试将更改推送到其他人之前编辑过的文件。这是上面列出的错误出现的时候。

查看 RHEL 的权限,似乎 repo.git/objects 中的文件夹设置为 755。 我相信发生的事情是当一个对象文件夹由用户 A 拥有时,用户 B 无法将更改推送到受影响的文件。作为说明,我已经让所有用户将他们在 git-bash 中的 umask 更新为 0002(从默认的 0022)。此外,repo.git 存储库中的所有文件/文件夹都归“DTG”组所有,所有使用此存储库的用户都属于该组。

尝试修复 我已尝试通过其他几种方式创建/初始化存储库,但每种方式都有相同的结果:

Create repo2.git
  git init --bare repo2.git
  cd repo2.git
  git config core.sharedRepository group
  chgrp -R dtg .
  chmod -R g+w . 
  chmod g+s `find . -type d`

Create repo3.git
  git init --bare repo3.git
  cd repo3.git      
  chgrp -R dtg .
  chmod -R g+w . 
  chmod g+s `find . -type d`
  git init --bare --shared=all 

Create repo4.git
  git init --bare repo4.git
  cd repo4.git 
  git config core.sharedRepository true     
  chgrp -R dtg .
  chmod -R g+swX . 
  chmod g+s `find . -type d`
  git init --bare --shared=all 

我还尝试让用户在设置本地 sharedRepository 配置时克隆存储库

git clone --config core.sharedRepository=true Z:/git_repo_location/repo.git

到目前为止,唯一可以解决此问题的方法是,如果我登录到 RHEL 计算机并将组权限添加到对象文件夹:

chmod -R g+w repo.git/objects/

问题在于,这只是解决眼前问题的临时创可贴。但是一旦有人再次推送更改,我就会留下缺少组写入权限的对象文件夹,下一个用户将再次被阻止。

如果能帮助解决这个问题,我们将不胜感激!!!另外,如果需要任何其他信息,请告诉我。上面大部分尝试的解决方案都来自另一个类似的问题 How to configure an existing git repo to be shared by a UNIX group

最佳答案

这似乎是文件共享中间层的问题。 假设您实际上正在使用 SAMBA 来提供要从 w32 guest 挂载的网络共享,umask 和类似的设置对您帮助不大(因为权限实际上是在处理由 samba 服务器和 w32 客户端 - 后者经常试图制作限制性很强的文件)

你可能会遇到这样的事情:

[git]
        comment = GIT repositories
        path = /path/to/git/repos
        read only = No
        force group = dtg
        create mask = 0664
        directory mask = 0775
        force directory mode = 0770
        force create mode = 0660

关于linux - Git Windows 多用户 - 组权限问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41192869/

相关文章:

git - Jenkins 管道 git 命令子模块更新

git - 我怎样才能回去测试哪里出了问题?

Git 如何对我已经推送的(个人)分支进行 rebase ?

linux - 在一个驱动模块中声明多个设备

LPR 命令的 Linux 打印问题

python - 拟合后如何获取lmfit参数呢?

windows - 无法在 cmd、Powershell 或 Vscode 中创建或更新文件。但我可以通过 Sublime、git bash 和文件资源管理器

linux - 如何通过性能测试中性能低的机器来计算算法在高性能机器上的性能?

linux - 蒲公英列表监听器失败

windows - 搜索具有特定文件内容的文件