开发者

Does a git repo always have to be in its own directory

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 submodul开发者_运维知识库e, 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


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜