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. 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.
Example开发者_运维百科: /www/project/.git
for all files except in /www/project/css
/www/project/css/.git
-> only files in this directory
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; 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. This sort of activity may be very familiar to CVS and (to a lesser extent) Subversion users. Gitslave's design is for simplicity for normal git operations.
I'll also point you to etckeeper which does track permissions. 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.
https://book.git-scm.com/book/en/v2/Git-Tools-Submodules
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.
精彩评论