How to create two Git repositories in the same base directory, without using branches?
We are currently in the process of moving our Magento Enterprise (an e-commerce web application) files into Git. The httpdocs/.gitignore file contains, among other things:
app/design/frontend/company/website/
skin/frontend/company/website/
After initializing, committing and pushing httpdocs/, our first Git repository was successfully created. We now want to put both of the aforementioned directories into their own, separate repository. (Together, in a single repository!) The problem we 开发者_如何转开发run into here is that these directories share a common root that already contains our first Git repository; that is: httpdocs/
I've read it is possible with the submodule functionality to embed other repositories within subdirectories of existing trees. However, the documentation at for example kernel.org and git-scm.com seems so complicated that it makes me wonder whether this is really the way to go forward. All we need is two separate repositories, they just happen to have the same root.
Another possible solution I've read about might be to initialize from app/design/frontend/company/website/ and add skin/frontend/company/website/ as a graft point in order to join these directories together. However, again, this seems overly complicated, and intended rather to be used when moving from another revision control system to Git.
You will have to use submodules or link the different repositories by sub tree merges.
If you go the submodule route, consider using gitslave as it will save you a lot of manual steps if you are actively developing both repositories.
Hope this helps.
You can look at subtree merging - which is sort of an alternative to using submodules
Go through the steps and understand what it does before going ahead.
Though like Anton, what you are trying to do may not be the best practice. In fact, it can lead you to other problems!
From git-1.7.11 on a subtree command was added to git. It does exactly what you want without the problems of submodules and without the hassle of subtree merging. (the subtree command is something different than subtree merging)
Here a related blog post: enter link description here
精彩评论