【问题标题】:Change GIT repository to shared将 GIT 存储库更改为共享
【发布时间】:2011-11-08 06:34:24
【问题描述】:

Git 允许在组之间创建共享存储库:

git --bare init --shared=group

但是 - 我如何将现有的存储库更改为共享?我不想重新 git-init 它。

【问题讨论】:

标签: git bash


【解决方案1】:

根据documentation

--共享[=(false|true|umask|group|all|world|everybody|0xxx)]

指定 git 存储库将在多个用户之间共享。 这允许属于同一组的用户推送到该存储库。 指定时,设置配置变量“core.sharedRepository”,以便 $GIT_DIR 下的文件和目录是使用请求的 权限。未指定时,git 将使用 umask(2) 报告的权限。

因此,为了更改权限,chmod 一切随心所欲,set the core.sharedRepository in git config 相应地:

git config core.sharedRepository true

【讨论】:

  • 试过这个:“git config core.sharedRepository=group”,但是当我测试“git config -l”时,该选项似乎没有出现。如何验证设置是否正确?
  • 用 git (rm file && git checkout file) 创建一个新文件,并确保它具有适当的权限(组可以读取)。
  • 正确的语法是 "git config core.sharedRepository true" -- 没有 "=".
【解决方案2】:

要共享一个私有的裸 repo 组:

  1. 编辑配置并将sharedRepository = group 添加到core 部分
  2. 从 repo 内部修复权限:
    • chgrp -R target-group .
    • find . -type d | xargs chmod g+ws
    • find refs -type f | xargs chmod g+w

【讨论】:

  • 非常糟糕的答案....sharedRepository = mygroup 返回remote: fatal: bad numeric config value 'mygroup' for 'core.sharedrepository': invalid unit 并且这些chmods 都没有修复权限。
  • 上面写着sharedRepository = groupnot sharedRepository = mygroup,也就是说,这不是你正在使用的组,但总是group。在示例中,您使用的组是 target group。如果您以足够的权限运行这些命令,它们肯定可以在任何类 Unix 操作系统上运行。
  • 执行--shared 似乎也将其添加到我的配置中:[receive] denyNonFastforwards = true。我假设在将现有存储库转换为共享存储库时手动添加它是个好主意。
猜你喜欢
  • 2012-02-11
  • 1970-01-01
  • 2019-02-10
  • 2011-03-21
  • 1970-01-01
  • 1970-01-01
  • 2014-10-05
  • 1970-01-01
  • 2015-04-06
相关资源
最近更新 更多