Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 205
Jakob Avatar asked Mar 25 '10 21:03

Jakob


People also ask

Can I have multiple Git repositories in one folder?

gitignore file. But sometimes there are situations where we might want to do something even fancier: Have some files of a directory in one repository, and others in another repository. This is not only possible, it's surprisingly easy and doesn't require complex Git knowledge with figures showing graphs, branches, etc.

Can I have multiple remote repositories in Git?

It is easy to synchronize code between multiple git repositories, especially, pushing to multiple remotes. This is helpful when you're maintaining mirrors / copies of the same repository. All you need to do is set up multiple push URLs on a remote and then perform git push to that remote as you usually do.

Can a project have multiple repositories?

As one of our most highly request features with Developer Community, we are so happy to announce the release of multi-repository support in Visual Studio 2022. Support for multiple repositories means you can have up to 10 active Git repositories at once.


2 Answers

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.

like image 127
Seth Robertson Avatar answered Sep 28 '22 14:09

Seth Robertson


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

like image 38
Xentac Avatar answered Sep 28 '22 15:09

Xentac