2

I am fairly new to git and have the following question:

I am developing a HTML/JS application. For the Backend I want to share the same codebase as the frontend (libs like jquery, a stub index.html, several helper files, standard css)

So i want to inlude the codebase repository and have an own repository for all changes on top (3 repositories alltogether: 1 codebase, 1 frontend, 1 backend). Like an application skeleton. Is this achievable with submodules? I want to have the possibility to push changes to the codebase or the project repository.

For example:

public/
|_ index.html
|_ css/
   |_ styles.css

If I change the index.html to include a js lib to use with the codebase I want to be able to push to the codebase. If I change the title Tag of the index.html I want to be able to push that change to the projects repository and leave the codebase unaffected.

Ben James
  • 121,135
  • 26
  • 193
  • 155
Riebel
  • 789
  • 2
  • 10
  • 22

2 Answers2

1

Submodules are a good way to reuse independent set of files, but you shouldn't mix submodules and the actual directory structure you will need.

Parent repo
  common    (submodule)
  codebase  (submodule)

This is different from your actual structure

public/
|_ index.html
|_ css/
   |_ styles.css

The way you can link both together is through symlinks (which exists even on Windows Vista or Seven), in order to modify what you want in your usual directories, but to commits in the actual Git repo working trees.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • OK, i should not mix submodules (but possible?) and it is not possible to push a changed file (symlinks would be no help here) back to a specific repository depending on the changes made? Is there another solution to my use case? – Riebel Dec 19 '11 at 20:40
1

Yes, submodules will do. I have not needed to use symlinks. I have one submodule that houses 3rd party dlls, one that houses common code including backend and one that has the app logic.

app level
 |
 |-- common code
      |
      |-- Libs

One word of advice, don't use spaces in your directory names.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141