tags:

views:

55

answers:

2

I would like to have multiple files in a folder with are managed by different git repositories. Is it possible?

I have the following folder structure for a project. It is part of a Git repository:

plugins/
 - plugin.a.php
 - plugin.b.php
 - plugin.c.php

I would like plugin.b.php to be part of another repo. For example, I want the development of this plugin to be hosted on github. To use and develop concurrently on different projects.

When I use a git submodule for plugin.b.php, I need an empty folder to init the submodule, so I have a structure of:

plugins/
 - plugin.a.php
 newfolder/
     - plugin.b.php
 - plugin.c.php

plugin.b.php will not load as, for example, my App only loads files from the root of plugins/. And, I don't want to have to modify the App.

Is there anyway to do this? I can think of lots of situations where I would like to use a similar workflow. Even having both plugin.b.php and plugin.c.php in different repos.

Thanks

+2  A: 

Have a look at --git-dir, --work-tree, GIT_DIR and GIT_WORK_TREE.
You should be able to create a repository somewhere else and set it's working directory to your normal path. Just add the one file to the second repository.

tanascius
this would be perfect. away to look into it...
Ross
@tanascius thanks. Marked your answer correct. Used a different solution, posted it below.
Ross
+2  A: 

See @tanascius' answer which provides the correct answer to using multiple git repos in one directory.

I am tentativly answering my own question in relation to: the question's example and GitHub. As there is a small caveat...

It is not possible for pluginb & pluginc to have same named files in the plugins folder. Although this is unlikely, as github repos, they both have github README files causing a conflit.

For this low file count situation I've settled for using a symbolic link (and keeping the repos inside the main repo which is optional):

.git/
.gitignore = .repos/
.repos/
     .git/
     - pluginb/
         README
         plugin.b.php
     - pluginc/
         README
         plugin.c.php
plugins/
     - plugin.a.php
     - symbolic-link = plugin.b.php
     - symbolic-link = plugin.c.php
Ross