mathlete
mathlete

Reputation: 6682

git submodules: Which repository shall be used as the 'submodule'?

I have a private git repository (repos 'private') with a bunch of files in them I frequently edit. Some of these files are published on a website. It is tedious to update these files every time I make a small change. I therefore thought of using git submodules in the following way: I set up a second (now public) git repository ('public'), and put in all files which appear on the website. The website then provides links to these files in 'public'. Once I edit one of the files in 'private' which are also in 'public', the changes in 'public' will be visible (after a simple git command) and the file changes will thus be visible on the website. My questions are:

1) Is this a good approach to deal with the problem?

2) I read about git submodule update --remote --merge but I'm still not 100% sure whether this updates the submodule to changes in the main project or exactly the opposite. I frequently see the wor 'upstream' used in explanations but couldn't find an exact definition.

3) If submodules are mainly used in the sense that one updates the main project to changes in the submodules, would I then have to create the 'private' repository as a submodule and the 'public' one as the main project? (because I would like to track changes to 'private' from within 'public')

[I thought I still keep these questions in a single post as they are quite related.]

Upvotes: 0

Views: 48

Answers (1)

Mathiasdm
Mathiasdm

Reputation: 1831

Using submodules adds quite a bit of complexity.

It seems like it would be easier to have a single repository, with a directory 'private' and a directory 'public'. The directory 'public' could contain symlinks to the files in 'private'.

This would allow you to have 2 types of files but avoid the complexity of submodules.

Another option would be to have your build system handle this: have only a single directory containing all files, and have a Makefile target which copies the public files to another directory.

Upvotes: 1

Related Questions