简体   繁体   English

一个目录中有多个Git存储库

[英]Multiple Git repositories in one directory

I would like to deploy a directory to multiple developers having different permissions. 我想将目录部署到具有不同权限的多个开发人员。 So this is one thing Git cannot do. 所以这是Git无法做的一件事。 What about creating two repositories in one directory and assigning them different file lists by excluding files managed by the other repository with the .gitignore file. 如何在一个目录中创建两个存储库并通过使用.gitignore文件排除由另一个存储库管理的文件,为它们分配不同的文件列表,该怎么办?

Example: /www/project/.git for all files except in /www/project/css /www/project/css/.git -> only files in this directory 示例: /www/project/.git用于除/www/project/css /www/project/css/.git所有文件->仅此目录中的文件

Has anyone tried this solution? 有没有人尝试过这种解决方案? Or are there any better ways to handle this issue? 还是有更好的方法来解决此问题?

A less annoying approach than git-submodules (which are a pain to use) is gitslave Gitslave creates a group of related repositories—a superproject repository and a number of slave repositories—all of which are concurrently developed on and on which all git operations should normally operate; gitslave是一种比git-submodules烦人的方法(使用起来很麻烦gitslave Gitslave创建了一组相关的存储库-超级项目存储库和许多从属存储库-所有这些都同时开发并在其上进行所有git操作正常运行; so when you branch, each repository in the project is branched in turn. 因此,当您分支时,项目中的每个存储库都会依次分支。 Similarly when you commit, push, pull, merge, tag, checkout, status, log, etc; 同样,当您提交,推,拉,合并,标记,签出,状态,日志等时; each git command will run on the superproject and all slave repositories in turn. 每个git命令将依次在超级项目和所有从属存储库上运行。 This sort of activity may be very familiar to CVS and (to a lesser extent) Subversion users. CVS和Subversion用户(在较小程度上)可能非常熟悉这种活动。 Gitslave's design is for simplicity for normal git operations. Gitslave的设计是为了简化常规git操作。

I'll also point you to etckeeper which does track permissions. 我还将指出您要跟踪权限的etckeeper It has its own peculiarities which may or may not make it usable for you. 它有其自身的特性,可能无法使您使用。

Finally, I'll note you can have a custome post-checkout script which sets the appropriate permissions on the appropriate files/directories. 最后,我会注意到您可以有一个定制的检出后脚本,该脚本在适当的文件/目录上设置适当的权限。

It sounds like you want submodules. 听起来您想要子模块。 Any sub directories from the main repo can be submodules which are different git repositories. 主仓库中的任何子目录都可以是不同git仓库的子模块。

https://book.git-scm.com/book/en/v2/Git-Tools-Submodules https://book.git-scm.com/book/zh/v2/Git-Tools-Submodules

http://git-scm.com/docs/git-submodule http://git-scm.com/docs/git-submodule

I suspect you're much better off permissioning your developers for comimits in either/both repositories. 我怀疑您最好允许开发人员在两个存储库中进行开发。 See also this server fault question . 另请参阅此服务器故障问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM