user58777
user58777

Reputation:

Techniques to handle a private and public repository?

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:

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?

Upvotes: 3

Views: 497

Answers (2)

VonC
VonC

Reputation: 1324268

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.

Upvotes: 2

mlathe
mlathe

Reputation: 2385

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.

Upvotes: 0

Related Questions