Reputation: 63
This is a question that seems to come up semi-frequently, but sadly I've not found an answer that I can fully apply to my situation yet, so I figured I'd ask my own question. This is my first question on SO, so be nice. :P
The "problem": Our company develops multiple PHP applications, however one of those applications is a "master" of sorts. All of our other applications is installed inside this "master application", and requires the master application to work.
We use version-control to manage these applications, of course.
While many of the files in our addon applications are in subdirectories, not all of them are. This means that we cannot use subdirectory importing (svn externals, git submodules, etc.). For instance, within the root folder there are several folders (admin, public, kernel and so on) and the addon applications have files within one or more of these folders - they are not independently self-contained within the directory structure of the master application.
We currently use SVN and recently found ourselves considering git due to some of the features available we feel could be useful to us. One thing I'm not clear on with git, however, is if there is truly a way to "merge" (not in the version control sense) these repositories into a single directory locally when developers are working on the code. I have not found a way to do this with SVN either.
In an ideal world, we would have one repository for our "master" application with a structure like so:
Our addon application would have a structure like so (remember, we have multiple addon applications):
We have experimented with the following approaches, each with its own caveats:
Is there any way with git or SVN (or any other version control system for that matter) to allow more than one repository within a single directory without using subdirectories? SVN externals is nearly perfect, but has the requirement that all files in the external repository be in a separate subfolder, which as described above does not work for us. I gather git has equivalent capabilities, but again cannot allow more than one repository in a single folder, leaving us with the same issue.
Related questions: Multiple repositories in one directory (same level) - is it possible? - this is very close to what I am asking I think, but I did not see any solution that I felt could be applied to our situation.
Upvotes: 6
Views: 1090
Reputation: 868
Subversion 1.6 and 1.7 allow externals of a single file.
See http://svnbook.red-bean.com/en/1.7/svn.advanced.externals.html
"Subversion 1.6 also introduced support for external definitions for files. File externals are configured just like externals for directories and appear as a versioned file in the working copy.
For example, let's say you had the file /trunk/bikeshed/blue.html in your repository, and you wanted this file, as it appeared in revision 40, to appear in your working copy of /trunk/www/ as green.html."
Upvotes: 2
Reputation: 129526
git allows you to specify work-directory and git-directory on the top level git command:
git status
can be altered to use a different .git folder with
git --git-dir=some/other/path/to/a/different/.git/folder status
Likewise, you can specify a different working folder:
git --work-tree=some/other/path status
You can also combine the 2.
If you have to have this workflow all the time, you can override and wrap the git command to always point to a specific .git dir or work dir. An example is "git achievements" which intercepts git commands and gives you rewards for getting better with git and then calls the actual git command: https://github.com/icefox/git-achievements
Looks like a fun problem to solve.
I would also look at just having a branch per application and continually rebase those branches on top of any work that is done to the core app. This would actually be my first choice.
Upvotes: 3
Reputation: 212168
I have never attempted to do something like this in a production environment, but you could certainly do:
$ git init $ mv .git .git1 $ git init $ mv .git .git2 $ export GIT_DIR=.git1 # do work in first repo $ export GIT_DIR=.git2 # do work in second repo
Upvotes: 3