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.
Idea开发者_Python百科lly 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?
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.
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.
精彩评论