4

I'm doing a project that will have these 3 components (all working together):

  • Custom server-side code
  • Custom client-side code
  • One 3rd party library that is a GitHub project (BSD licensed)

As part of the development, it is likely that I will make changes to the 3rd party library project and that I will want to contribute my changes back to the project owner, preferably via GitHub fork / pull request.

The question is, how do I structure my repository (repositories) if I don't want it to be entirely open-source and hosted on GitHub? If it were 100% closed-source, I would have one repository with 3 main folders, something like ServerSide, ClientSide and LibraryXY but I guess copying the contents of the 3rd party library to LibraryXY would make it difficult to contribute changes to it back to the project owner on GitHub.

Borek Bernard
  • 50,745
  • 59
  • 165
  • 240

1 Answers1

3

You can use either git submodule or git subtree commands.

A submodule in a git repository is like a sub-directory which is really a separate git repository in its own right. This is a useful feature when you have a project in git which depends on a particular versions of other projects. see details

Subtrees allow subprojects to be included within a subdirectory of the main project, optionally including the subproject's entire history. For example, you could include the source code for a library as a subdirectory of your application. see details

Based on your project structure, I would suggest you use git subtree

maxk
  • 642
  • 1
  • 9
  • 21
  • Thanks. From the description, submodule seems to be the thing that I am looking for - having 3 directories and one of them somehow configured to fetch the sources from GitHub sounds right. Will I be able to "push" changes made to that sources back to GitHub or is it one way only? – Borek Bernard Dec 17 '11 at 15:36
  • You should be able to do that: [http://stackoverflow.com/questions/5814319/git-submodule-push](http://stackoverflow.com/questions/5814319/git-submodule-push) – maxk Dec 17 '11 at 15:39
  • @Borek A submodule is a full-fledged repository on its own. So yes. Be aware that the `submodule` mechanism is not as well designed as other parts of git and can be a little confusing at times. – pmr Dec 17 '11 at 15:52