0

I have a folder structure similar to:

src

  • .git
  • Folder1
    • folder1file1
    • Common (inside this folder are commonfile1 and commonfile2)
  • Folder2
    • folder2file1
    • Common (inside this folder are commonfile1 and commonfile2)
  • Common
    • commonfile1
    • commonfile2

I used to have this in a SVN repository and recently moved to git, which I am just learning about. In SVN, Common was its own repository and Folder1 and Folder2 used External References to the main Common folder to reference into the Common folder under Folder1 and Folder2. So anytime I wanted to make a change to commonfile1 all I had to do was SVN Update in Folder1 and the latest changes inside Common would come over.

So considering this same folder structure in git (with everything under src being in the same git repo) how can I achieve the same functionality? I simply want to be able to use Folder1.Common and Folder2.Common like submodules. Is this possible with the main Common folder being part of the same master repository?

Adam Baruh
  • 11
  • 3

1 Answers1

0

You can accomplish this with

  1. Have 2 or more separate repositories and use git submodule. Personally I don't like it since it get a bit cumbersome.

  2. Use simlinks and have everything in one repository.

The choice comes down to the size of the repositories and ownership.

Zepplock
  • 28,655
  • 4
  • 35
  • 50
  • I considered just splitting Common into its own repository. Common is just contains a bunch of utility javascript functions so it's unlikely that when creating a branch that I would include changes to common in a branch. If changes in Common were something I wanted to isolate in a branch that would be a good case for a single repository but I suppose I won't be doing that all that much so I could employ a standard submodule scenario. I don't know about simlinks and will explore those. – Adam Baruh Aug 19 '15 at 18:44
  • Just be careful, symlinks are a bit tricky. If your Commons is a standalone library and you might eventually open it or have somebody else maintaining it - it's probably a better idea to make it a separate repository and use submodule. – Zepplock Aug 19 '15 at 18:48