3

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.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
Norbert
  • 990
  • 1
  • 8
  • 10
  • 1
    you cannot have two repositories with the same root dir. i guess using a submodule would be the only option – knittl Apr 20 '11 at 11:25
  • 4
    suggest you read git best practices first but if you indeed need two separate repos then create two folders and just symlink them to targets – Anton S Apr 20 '11 at 13:32
  • Anton, thank you for the symlink suggestion, it's what we'll go forward with. – Norbert Apr 21 '11 at 07:23
  • Anton, if you add it as an answer further down, I will select it as my accepted answer. I'm new on Stack Overflow, so I cannot yet vote up your comment in this section. – Norbert Apr 21 '11 at 08:06

3 Answers3

3

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.

Seth Robertson
  • 30,608
  • 7
  • 64
  • 57
Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
0

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

fivef
  • 2,397
  • 21
  • 21
0

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!

manojlds
  • 290,304
  • 63
  • 469
  • 417