views:

36

answers:

2

I have an open source'd website. Some content is "private" such as connection parameters, as well as files that the open source version doesn't need (eg. advertising templates).

Essentially I'm trying to maintain two versions:

  • A public site that has a unique identity (advertising, Google Analytics account, link for associated forum and so on)
  • An open source version for community development, without unnecessary dependencies or branding

Currently I'm using a .gitignore file to prevent the "private" content to be pushed to the open source repository. Along with a helper that includes templates that are found locally, but shows an empty box for the open source version.

This works well enough until I try to checkout between feature branches: a branch may need a new key in the settings file. Because the settings file is ignored by Git (to avoid push'ing passwords and so on), the site breaks.

Ideally I'd want to version control settings files, but to be able to tell Git not to ever push these files to a remote server (Github). Is that possible?

Should I use branches to manage different website versions instead?

A: 

Branches (as you suggested), is probably the most direct way to do this. In fact this is what they were meant to do, namely to separate multiple projects/versions from each other.

mlathe
+1  A: 

You should use git submodules with:

  • one module for all the public content, which can be pushed/pulled at will
  • one module for the private content
  • one super-project, also in a private repo, which references both the public and the private submodules.

Branches within one repo is not the answer, especially when dealing with sensitive informations.

VonC
Thanks this sounds like what I should do but I'm still too inexperienced with Git and that sounds over my head right now. Do you think there is a way to simply block git push from copying chosen files to a remote , or simply block from any pushes? My application can easily ignore the nopn-existing files in the open source version because it runs in a different mode. To be able for example to not ever push any ".*" file would be the easiest option. (I guess this won't make sense since the open source .git folder would have history for non existing files..:( )
faB
@faB: You could prevent push through hooks on the local or the destination repo side (some `git-receive-pack` on the remote repository, see also http://benjamin-meyer.blogspot.com/2008/10/git-hooks.html), but since hooks are not share with push/pull operations through the different remote repo (see http://stackoverflow.com/questions/1717278/git-hooks-and-how-they-work), I am always reluctant to use them (because of the all additional setup you need to do on the repo). Since submodules are easier to control, I prefer that solution.
VonC